[comp.lang.c] #ifdef without identifier

dolf@idca.tds.PHILIPS.nl (Dolf Grunbauer) (12/14/90)

We just traced a wierd bug.  After some debugging it turned out that parts
of the code was not compiled. The code was something like:

#ifdef	/* FLAG */
	do_something();
#endif

Obviously the source was compiled with -DFLAG. The code between the #ifdef
and #endif was not included in the compilation and everyone looked over this
error (?). The compiler gave no warnings or errors, but I think it should do
so in this case as an 'ifdef' always requires an identifier, or do I miss
something ? I also tried just a plain '#ifdef' on a line and this too is
accepted by our compiler (i.e. code is not included in the compilation).
-- 
   _ _ 
  / U |  Dolf Grunbauer  Tel: +31 55 433233 Internet dolf@idca.tds.philips.nl
 /__'<   Philips Information Systems        UUCP     ...!mcsun!philapd!dolf
88  |_\  If you are granted one wish do you know what to wish for right now ?

steve@taumet.com (Stephen Clamage) (12/16/90)

dolf@idca.tds.PHILIPS.nl (Dolf Grunbauer) writes:

|We just traced a wierd bug.  After some debugging it turned out that parts
|of the code was not compiled. The code was something like:

|#ifdef	/* FLAG */
|	do_something();
|#endif

|Obviously the source was compiled with -DFLAG. The code between the #ifdef
|and #endif was not included in the compilation and everyone looked over this
|error (?). The compiler gave no warnings or errors, but I think it should do
|so in this case as an 'ifdef' always requires an identifier...

According to the ANSI standard, #ifdef must be followed by an identifier,
and the compiler must reject as an error the code as given.  If your
compiler is intended to be ANSI-compliant, you have a legitimate cause
for complaint to the vendor.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com