quotes inside #if 0

Joerg Lehners lehners at uniol.UUCP
Thu Sep 7 08:41:27 AEST 1989


diomidis at ecrcvax.UUCP (Diomidis Spinellis) writes:
>[some text deleted]

>ecrcvax% cat t.c
>#if 0
>#funny_text
>/*
>#endif
>ecrcvax% /bin/cc -c t.c
>t.c: 2: undefined control
>t.c: 5: unterminated comment

>Vanila pcc complains about unbalanced comments and undefined preprocessor
>controls inside #if 0 blocks.  Commenting out arbitrary text with #if 0 is
>not a safe practice for most compilers (both ANSI and classic C).

I think the preprocess must look at the code following the #if 0 because
the preprocessor must look for the corresponding #endif.
And the rules for the preprocessor are: don't do any substitutions
an interpretation in constant character arrays (""),
character constants ('') and comments (/* */).

But the idea of non-interpreting #if 0 / #endif pairs would be very nice:
to (totally) comment out a full chunk of nontestet, non " and '
balanced code but /* */ balanced code, without worrying about recursive
comments.

  Joerg
--
/ Joerg Lehners                       | Fachbereich 10 Informatik ARBI   \
|                                     | Universitaet Oldenburg           |
| BITNET/EARN: 066065 at DOLUNI1.BITNET  | Ammerlaender Heerstrasse 114-118 |
| UUCP/Eunet:  lehners at uniol.uucp     | D-2900 Oldenburg                 |
+-------------------------------------+----------------------------------+
\          Unix-Wizards: let's zap away all stupid users.                /



More information about the Comp.lang.c mailing list