Code:
#include <stdio.h>
struct g {} f;
int main ()
{
#if '\0'
printf ("\nTomato\n");
#elif 10
printf ("\nPotato %u\n", f);
#elif f
printf ("\nLadyfinger\n");
#endif
}
The output of the above code is:
Code:
anisha@linux-uitj:~/junk/preprocessor> gcc hello.c
anisha@linux-uitj:~/junk/preprocessor> ./a.out
Potato 562924280
This proves that f has a non zero value, so I modified the above code as follows:
Code:
#include <stdio.h>
struct g {} f;
int main ()
{
#if 0
printf ("\nTomato\n");
#elif 0
printf ("\nPotato %u\n", f);
#elif f
printf ("\nLadyfinger\n");
#endif
}
Now the first two if / else conditions fail since they are false but shouldn't the third get executed since f has the non-zero value ???
But the output is nil:
Code:
anisha@linux-uitj:~/junk/preprocessor> gcc hello.c
anisha@linux-uitj:~/junk/preprocessor> ./a.out
anisha@linux-uitj:~/junk/preprocessor>
Why it is so ?