C, embedded comments and preprocessors
Karl Heuer
karl at haddock.ima.isc.com
Thu Sep 20 13:53:32 AEST 1990
In article <1990Sep20.000536.19987 at ccu.umanitoba.ca> mills at ccu.umanitoba.ca (Gary Mills) writes:
>lwv27 at CAS.BITNET writes:
>>I have for some time commented out portions of code by surrounding them by
>>a construct similar to: [attempt to use /* ... /* ... */ ... */]
No offense, but I'm astounded that some people think nested comment-parsing
is normal behavior. (Whether it *should* be is irrelevant. The fact is that
it isn't and never has been%.)
>A better way to remove some code from the compilation is with:
> #ifndef OLD_STUFF
> lines of code /* line comment */
> lines of various text's comments
> lines of code /* line comment */
> #endif
No, that still won't work$. The middle line of those three was commentary
rather than code, and the apostrophe is still an unclosed character constant.
The correct solution is to use /*...*/ for comments and #if...#endif for code
removal, e.g.
#if 0
lines of code /* line comment */
/*
lines of various text's comments
*/
lines of code /* line comment */
#endif
Karl W. Z. Heuer (karl at kelp.ima.isc.com or ima!kelp!karl), The Walking Lint
________
% Don't bother telling me it works in *your* compiler. I don't care; it still
isn't legal.
$ See previous footnote.
More information about the Comp.lang.c
mailing list