msbuild: set a specific preprocessor #define in the command line

后端 未结 11 1636
借酒劲吻你
借酒劲吻你 2021-02-01 05:08

In a C++ file, I have a code like this:

#if ACTIVATE
#   pragma message( \"Activated\" )
#else
#   pragma message( \"Not Activated\")
#endif

I

11条回答
  •  抹茶落季
    2021-02-01 05:36

    As @bigh_29 has mentioned, using environment variables to define or undefine a preprocessor.

    What he suggested the way to undefine a preprocessor is actually /UACTIVATE.

    This way, any preprocessor matching ACTIVATE will be negated and compiler wouldn't go through your #if ACTIVATE #endif enclosure.

提交回复
热议问题