Funny if only marginally related fact: even though neither the C++11 syntax
if (int x = foo(); x) { ... }
nor the C++98 syntax if (int x = foo()) { ... }
is supported in C99, it still introduces the rule that the entire if statement is a scope (which it wasn’t in C89). So as a party trick, here’s a way to check for C99 without using the preprocessor: int c99() {
enum { C99 = 1 };
{
if (sizeof(enum { C99 = 0 })) { }
return C99;
}
}
I make no promises about the behaviour of this code on insufficiently anal compilers like TCC.