defining a comment?

Len Reed lbr at holos0.UUCP
Thu Sep 15 23:33:21 AEST 1988


>From article <13544 at mimsy.UUCP>, by chris at mimsy.UUCP (Chris Torek):
> In article <5438 at techunix.BITNET> benny at techunix.BITNET (Benny Pinkas) writes:
>>Can I use the Preprocessor to define a comment?
> 
>>#define STARTCOM /*
> 
> This is rather dubious.
> 
>>Usually the text after the /* is considered as a comment and is not part
>>of the macro definition.
> 
> Why should you care?  You cannot (portably) view the text (if any) emitted
> by the preprocessor, which may well be an integral part of the compiler.

You misunderstand.  On Xenix and MSC 5.x (where I've tried this) consider:

#define COMMENT /*
#define CLOSE_COMMENT */

The pre-processor considers these two lines to be functionally equivalent
to the single line:

#define COMMENT /* #define CLOSE_COMMENT */

which is no different than

#define COMMENT

This is because comment structures are parsed in the 1st pass before #defines.
Comments are not stored in the pre-processor lookup table.
Later when you say:

COMMENT
	A whole bunch of stuff
CLOSE_COMMENT

the compiler tries to compile

	A whole bunch of stuff
CLOSE_COMMENT

and messes up.
-- 
    -    Len Reed



More information about the Comp.lang.c mailing list