Someone claimed in a presentation that if you add
#define struct union
#define else
at the beginning of any valid C program, that program would still compile. That seems like a bold claim. Any counterexample you have in mind and prove that guy wrong?
I managed to find a counterexample (C99):
for (int i = 0; i < 5; ++i)
if (i > 2)
do_smth();
else if (i < 4)
do_smth_else();
This one doesn't compile because if you #define else
the variable i
goes out of scope. But that doesn't involve the #define struct union
thing. Any other ideas?
#define struct union
struct OBJ
{
int i1;
double d1;
};
int foo()
{
struct OBJ obj = { 1, 2.0 };
return 0;
}
C2078: too many initializers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With