quotes inside #if 0

Diomidis Spinellis diomidis at ecrcvax.UUCP
Wed Sep 6 17:41:27 AEST 1989


In article <2023 at munnari.oz.au> ok at cs.mu.oz.au (Richard O'Keefe) writes:
>In article <2014 at munnari.oz.au> ok at cs.mu.oz.au (Richard O'Keefe) writes:
>>	#if 0 ... [English text and C examples] ... #endif
>>The compiler sees words like "don't" in the English text and snarls that
>>these are unterminated character constants.  This used to be perfectly
>>good C...
[...]
>It is not at all coincidental.  There was never any suggestion in any book
>that #if 0-ed code had to have balanced single quotes, and the only C
>compiler I've ever come across (I've used about a dozen) that complains
>about it is the only one I've used that tries to be ANSI-compliant.

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).

Diomidis
-- 
Diomidis Spinellis          European Computer-Industry Research Centre (ECRC)
Arabellastrasse 17, D-8000 Muenchen 81, West Germany        +49 (89) 92699199
USA: diomidis%ecrcvax.uucp at pyramid.pyramid.com   ...!pyramid!ecrcvax!diomidis
Europe: diomidis at ecrcvax.uucp                      ...!unido!ecrcvax!diomidis



More information about the Comp.lang.c mailing list