开发者

C preprocessor vs. C compiler

If I tell the C preprocessor to #include a file and use CPPFLAGS to help find the needed file, then the file is included already, right? What, if any, use is telling the C compiler abou开发者_JAVA百科t the same include directory with CFLAGS?


I don't think there is any use.

The implicit make rules indicates that CFLAGS is only used when compiling C programs (from .c to .o). The value of CPPFLAGS is also added to the compiler command line.

CPPFLAGS is also used in the following rules:

  • Compiling C++ programs
  • Compiling Fortran and Ratfor programs
  • Preprocessing Fortran and Ratfor programs
  • Assembling and preprocessing assembler programs
  • Making Lint Libraries from C, Yacc, or Lex programs

Since CPPFLAGS is used in every case where CFLAGS is used, there seems to be no point in adding -I directives to CFLAGS that are already in CPPFLAGS.

Of course, if your Makefile has custom rules that pass CFLAGS to the compiler, but omit CPPFLAGS, it's a different story.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜