buildc-preprocessor

Are "-D" (define) macros ever relevant to the compiler on already-preprocessed C/C++?


Do any C/C++ compilers (not preprocessors) ever consider-as-significant macros defined at the command-line? This question includes both user-defined macros and well-known (compiler-or-system-specific) macros.

(I'm not asking about compiler-switches, but rather, only that SINGLE switch-to-define-macros at the command line.)

For example, if you've already "pre-processed" the myfile.cpp to a myfile.i, and then want to compile that myfile.i to a myfile.obj/myfile.o, does it EVER make sense to have -Dmacro to define some "macro" at the command-line for the myfile.i==>myfile.obj/myfile.o?

Similarly, does the linker EVER consider-as-significant macros (defined anywhere)?


Solution

  • Yes.

    Some debugging formats will record the preprocessor definitions so they can be accessed from within the debugger.

    (But I know of no linker which accepts preprocessor flags.)