[3875] in Athena Bugs

home help back first fref pref prev next nref lref last post

Re: GCC preprocessor

daemon@ATHENA.MIT.EDU (Ken Raeburn)
Tue Jan 2 13:58:32 1990

Date: Tue, 2 Jan 90 13:58:06 -0500
From: Ken Raeburn <Raeburn@ATHENA.MIT.EDU>
To: dussart@ATHENA.MIT.EDU
Cc: bugs@ATHENA.MIT.EDU
Cc: gnu@ATHENA.MIT.EDU
In-Reply-To: Jean E Dussartre's message of Tue, 02 Jan 90 13:38:14 EST,

The GCC preprocessor is correct.  According to sections 3.8.3.2 and
3.8.3.3 of the pANS (my copy is dated May 1988), the "#" and "##"
operators are only valid in the replacement list of a function-like
macro; I do not believe they can appear anywhere else.

If you want to use the stringified version of an identifier, you must
use a macro to get it.  For example:

#define stringify(X) # X

Due to the order of evaluation in the preprocessor, if you don't want
the literal argument quoted, but instead want its (post-preprocessing)
value quoted, you must do something like this:
	#define string2(X)	# X
	#define stringify(X)	string2(X)
	stringify(BUF_MAX)
The reason for this is that
	string2(BUF_MAX)
expands to
	"BUF_MAX"
but
	stringify(BUF_MAX)
expands to
	string2(128)
which produces the results you want.

In the future, please direct questions and bug reports about gcc (and
anything else in the "gnu" file system) to "gnu@athena.mit.edu".
Project Athena does not support this software, and should not be sent
bug reports about it; several individuals on that list (some of whom,
like myself, do work at Athena) handle the local support.

-- Ken Raeburn
   Project Athena Systems Developer
   (and a local GNU software supporter)

home help back first fref pref prev next nref lref last post