From: Lew Randerson <lranderson () Pppl ! GOV>
To: tru64-unix-managers
Subject: Embedding # in C preprocessor macros
Date: Mon, 09 Feb 1998 16:23:09 +0000 [thread overview]
Message-ID: <96078694111199.tru64-unix-managers.marc@archive.invalid> (raw)
Re: Embedding # in C preprocessor macros
The following file
#define ATFB(X) mx#0
ATFB(a)
When run through /usr/ccs/lib/cpp on a Digital Unix v4.0B machine
gives:
# operator should be followed by a macro argument name
What's the portable way of including # in macro bodies?
--------------------------------------------------------------------
This problem is caused by the addition of 'stringification' aka
'stringization' of tokens which was added to ANSI C. So something
like:
#define TEST(a,b) prinf( #a "<" #b "=%d\n", (a)<(b) )
TEST(0,0xFFFF);
will now under ANSI C become
printf("0<0xFFFF=%d\n", (0)<(0xFFFF) );
In traditional C according to the non-Digital documentation I have:
* The character `#' has no special meaning within a macro
definition in traditional C.
So my question then becomes
1) Is there a way to turn off stringification in cpp?
or
2) Is there a way to use # in a macro body even with
stringification turned on.
Thanks for any help.
--Lew
lranderson@Pppl.GOV
reply other threads:[~1998-02-09 16:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox