C macro to enable and disable code features

前端 未结 6 1641
Happy的楠姐
Happy的楠姐 2021-01-07 09:44

I\'ve used a code base before that had a macro system for enabling and disabling sections of code. It looked something like the following:

#define IN_USE            


        
6条回答
  •  隐瞒了意图╮
    2021-01-07 10:22

    Couldn't you just use another group of #ifdefs?

    #if defined(WIN32)
        #define FEATURE_A
        #define FEATURE_B
    #elif defined (OSX)
        #define FEATURE_C
    #endif
    
    // ...
    
    #if defined(FEATURE_A)
        do_a();
    #endif
    

    etc.

提交回复
热议问题