How to add a 'or' condition in #ifdef

前端 未结 3 1271
情话喂你
情话喂你 2020-12-22 21:15

How can I add a \'or\' condition in #ifdef ?

I have tried:

#ifdef CONDITION1 || CONDITION2

#endif
3条回答
  •  清歌不尽
    2020-12-22 22:07

    May use this-

    #if defined CONDITION1 || defined CONDITION2
    //your code here
    #endif
    

    This also does the same-

    #if defined(CONDITION1) || defined(CONDITION2)
    //your code here
    #endif
    

    Further-

    • AND: #if defined CONDITION1 && defined CONDITION2
    • XOR: #if defined CONDITION1 ^ defined CONDITION2
    • AND NOT: #if defined CONDITION1 && !defined CONDITION2

提交回复
热议问题