Override macro from the command line

后端 未结 3 1563
猫巷女王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:19

    If you are trying to make something that is configurable from the command line, and you can change the source code, then you can use #ifndef to define the macro only if it is not already defined. So when you define the macro, the code will see it and not overwrite it, but if you don't define it it will have a default value.

提交回复
热议问题