This one bit me today

David Battle battle at alphard.cs.utk.edu
Fri Dec 15 02:16:23 AEST 1989


In article <426 at jhereg.Minnetech.MN.ORG> Mark H. Colburn writes:
>In article <1989Nov28.145229.27060 at sssab.se> [...] (Paul Svensson) writes:
> >#ifdef notdef
> >	"!%()[]/*",
> >#endif
> >
> >I know at least one compiler that fail to realize that this does not
> >start a comment.
>
> Get a new compiler.  That one is busted...

What SHOULD the following program do?  Why?

#ifdef NOTDEF
/*
#endif

#define COMMENT_NOT_EFFECTIVE 1

#ifdef NOTDEF
*/
#endif


int main(int argc, char **argv)
{
#ifdef COMMENT_NOT_EFFECTIVE
    (void) printf("#ifdef takes precidence.\n");
#else
    (void) printf("/* takes precidence.\n");
#endif
    return 0;
}

					-David L. Battle
                                         battle at battle.esd.ornl.gov
					 battle at utkvx2.BITNET



More information about the Comp.lang.c mailing list