I have the following code:
#include <stdio.h>
enum {A, B};
#define C A
int main() {
#if C == B
printf("%d==%d\n", C, B);
#else
printf("%d!=%d\n", C, B);
#endif
}
which, surprinsingly, gives the output:
0==1
Now, I understand that the code is wrong, because enum values are unknown to the preprocessor. What I don't understand is why no error is generated... A and B should be undefined at preprocessing time, how is that the preprocessor gives no error?