#if preprocessor directive for directives other than DEBUG

前端 未结 4 2069
暖寄归人
暖寄归人 2020-12-30 19:13

I know that I can use preprocessor directives to check for Debug/Release by doing this:

#if DEBUG
    //debug mode
#elif
    //release mode
#endif

4条回答
  •  天涯浪人
    2020-12-30 19:41

    It's the same as for DEBUG, assuming that you've defined a build configuration that lists TEST in the "Conditional compilation symbols" text box (under project properties > Build tab; this is a space-delimited list).

    For code that you only want to run in the TEST build configuration:

    #if TEST
    // ...
    #endif
    

    And for code you don't want to run in the TEST build configuration, you can either #else the above, or do this:

    #if !TEST
    // ...
    #endif
    

提交回复
热议问题