Boolean in ifdef: is “#ifdef A && B” the same as “#if defined(A) && defined(B)”?

后端 未结 5 409
慢半拍i
慢半拍i 2020-12-13 03:18

In C++, is this:

#ifdef A && B

the same as:

#if defined(A) && defined(B)

?

I was

5条回答
  •  不知归路
    2020-12-13 03:51

    For those that might be looking for example (UNIX/g++) that is a little different from the OP, this may help:

    `

    #if(defined A && defined B && defined C)
        const string foo = "xyz";
    #else
    #if(defined A && defined B)
        const string foo = "xy";
    #else
    #if(defined A && defined C)
        const string foo = "xz";
    #else
    #ifdef A
        const string foo = "x";
    #endif
    #endif
    #endif
    #endif
    

提交回复
热议问题