int main(void)
{
#if 0
something"
#endif
return 0;
}
A simple program above generates a warning: missing terminating " character
in gcc. This seems odd, because it means that the compiler allow the code blocks between #if 0
and endif
have invalid statement like something
here, but not double quotes "
that don't pair. The same happens in the use of #ifdef
and #ifndef
.
Real comments are fine here:
int main(void)
{
/*
something"
*/
return 0;
}
Why? And the single quote '
behave similarly, is there any other tokens that are treating specially?
See the comp.Lang.c FAQ, 11.19:
Under ANSI C, the text inside a "turned off" #if, #ifdef, or #ifndef must still consist of "valid preprocessing tokens." This means that the characters " and ' must each be paired just as in real C code, and the pairs mustn't cross line boundaries.
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