Re^2: Why nested comments not allowed?

Richard O'keefe ok at goanna.oz.au
Thu Feb 22 15:50:55 AEST 1990


In article <5372 at ur-cc.UUCP>, misu_ss at uhura.cc.rochester.edu (What`s in a name?) writes:
> This leads me to a question on how compilers work...
> Do #defines get worked out before comments are discarded...

It is quite explicit in ANSI C that comments are turned into spaces before
any preprocessor directives are recognised or processed.

In older C systems, particularly ones based on the "Reiser" preprocessor,
this wasn't true, but portable code never could exploit it so we haven't
lost anything.

A consequence of the ANSI rules is that

	#define OPEN_COMMENT /*
	extern int fred[];
	/* static */ int tom[2];

acts exactly like

	#define OPEN_COMMENT   int tom[2];

If you want to do hairy things with comments and macros, M4 comes as
part of the UNIX toolkit, and there's a PD implementation in C.



More information about the Comp.lang.c mailing list