/
Defining C Preprocessor constants from the command line

Defining C Preprocessor constants from the command line

This in a header file:

#define FOO_FUNKY_SWITCH 1

and this in a compiler invocation:

-DFOO_FUNKY_SWITCH=1

Do the same thing.

Personally I don’t love having my compiles filled with switches since it imposes extra cognitive load in my opinion when compiling code.

Related content

How can we make our code compile fast?
How can we make our code compile fast?
More like this
C API Pattern for Binary Compatibility
C API Pattern for Binary Compatibility
More like this
__FILE__ and __LINE__
__FILE__ and __LINE__
More like this
How do you get a compiler to generate dependency files
How do you get a compiler to generate dependency files
More like this
Make Dependency Files for C/C++ Headers
Make Dependency Files for C/C++ Headers
More like this
How do you see how the pre-processor processes code?
How do you see how the pre-processor processes code?
More like this