[C++11 16.1] , [C++11 16.5] and, by the way, [C99 6.10.1/4] all say that this is not true.
if-groups:
# if expression constant newline group opt
# ifdef identifier new-line group opt
# ifndef identifier new-line group opt
Only one identifier is allowed.
GCC's own documentation agrees .
My own tests assume that only the first identifier is accepted, and the second is simply discarded; this may be a simplification of implementation, but the standard requires diagnostics here, so you should see this when using the -pedantic flag of at least & dagger; .
#include <iostream> using namespace std; #define A #define B int main() { #ifdef A std::cout << "a "; #endif #ifdef B std::cout << "b "; #endif #ifdef C std::cout << "c "; #endif #ifdef BC std::cout << "bc "; #endif #ifdef CB std::cout << "cb "; #endif return 0; } // Output: "ab bc" // Note: "cb" *not* output
& dagger; The Coliru GCC installation emits with or without -pedantic .
source share