Why does the preprocessor process code in #if 0 ?
Chirayu Patel
chirayuATelwing.trillium.com
Thu Sep 16 17:50:00 GMT 1999
Hi,
Thanks for the response. I didnt think of this string case.
FYI,
cc -E (on solaris) reports a error when I compile this program.
-----------------------
#include <stdio.h>
main ()
{
#if 0
char a[]={"lkjfg
lskdjfg"};
#else
char a[]={"lkjfg
lskdjfg"};
#endif
}
-------------------------
If I change the second declaration of a[] to
char a[]={"lkjfg\
lskdjfg"};
cc -E dosent report any errors. This means cc is able to preprocess the code in
#if 0.
Dont know if the above is a compiler error or some option I am missing.
CP
Paul D. Smith <psmith@baynetworks.com> wrote:
> %% Chirayu Patel <chirayu@elwing.trillium.com> writes:
> In particular, character constants and strings must be properly
> terminated. Otherwise, the preprocessor would get very confused on code
> such as:
> #if 0
> "#ifdef FOO
> bar
> #else
> baz
> #endif"
> #endif
More information about the Gcc-help
mailing list