by mananaysiempre · 1y ago · 0 comments
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.https://github.com/ioccc-src/winner/blob/a1c86c8a7a533e3c2cd...
x*=02//* */2
-1;
With C89, this is evaluated as "x *= 02 / 2 - 1", or "x *= 0".With C99, this is evaluated as "x *= 02 / -1", or "x *= -2".
But tcc isn't a C++ compiler at all?
I think.