Override macro from the command line

后端 未结 3 1567
猫巷女王i
猫巷女王i 2021-01-04 12:50

I would like to override a macro from the command line. Somewhere in my source, there is a definition like this:

#define MY_FOO 1

What I wo

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-04 13:38

    You can't.

    The command line is handled before any source and header files.
    If a source file defines a macro, then it must not be defined before, and will get the new value from now on.
    The only way to change it, is to #undef and #define it again, at a later point. If you have access to a header that is included after the definition, then you have a chance.

提交回复
热议问题