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

后端 未结 5 402
慢半拍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:43

    They are not the same. The first one doesn't work (I tested in gcc 4.4.1). Error message was:

    test.cc:1:15: warning: extra tokens at end of #ifdef directive

    If you want to check if multiple things are defined, use the second one.

提交回复
热议问题