stupid C preprocessor question

Steven G. Kargl kargl@troutmask.apl.washington.edu
Wed Mar 24 16:35:00 GMT 2004


Zack Weinberg wrote:
> "Steven G. Kargl" <kargl@troutmask.apl.washington.edu> writes:
> 
> > I learned K&R C several years ago and now have a need
> > to return to programming in C.  Is the following legal C?
> 
> The only bit of your code that is objectionable is this bit
> 
> > #if 0
> >    Can't do this
> > #endif
> 
> which provokes undefined behavior, because of the unmatched single
> quote.  Use a real comment (/* Can't do this */) instead.
> 

I'm translating a large chunk of Fortran to C.  The use of
#if 0 ... #endif makes it much easier.  I don't have access to
the C99 standard, but Harbison and Steele state in a discussion
of #if ... #endif constructs that "A group of lines that is 
discarded is not processed by the preprocessor." (H&S, 5th ed.
page 62).  

kargl[202] gcc -c a.c
a.c:5:7: missing terminating ' character

It appears that gcc is preprocessing the discarded lines.

-- 
Steve
http://troutmask.apl.washington.edu/~kargl/



More information about the Gcc mailing list