ANSI Parsing/Preproc questions

Blair P. Houghton bhoughto at cmdnfs.intel.com
Tue Oct 16 02:07:38 AEST 1990


In article <383 at goya.dit.upm.es> esink at turia.dit.upm.es (Eric Wayne Sink) writes
>What does ANSI say about comments within tokens ?  ie, is the
>following legal ?
>int variable;
>vari/* in the middle */able = 5;

No.  The comment is whitespace.

>Also, does ANSI say anything about the preprocessor contructing tokens
>#define macro(X) variX
>/* obviously, some operator is needed above [...] */
>macro(5) = 3; /* expands to: vari5 = 3 */

Token-pasting.  Use the ## preprocessing operator as follows:

	#define macro(X) vari ## X
	/* there's the operator you wanted */
	macro(5) = 3; /* becomes vari5 = 3 */
	/* HOWEVER */
	#define FOO BAR
	macro(FOO) = 3; /* becomes variFOO = 3, _not_ variBAR = 3 */

>Finally, can anyone send me/point me to examples of C code which
>causes problems for parsers/preprocessors ?  I've heard something of a
>C torture test...

Anything I've written in the past ten years should do it :-).

>email FAQ to me ?)

Just keep on reading this group.  The abridged FAQ was
posted today, and the full text will be around in about two
weeks if the abridged version doesn't tell you enough.

				--Blair



More information about the Comp.lang.c mailing list