Change in preprocessor behavior
Stephen Lindholm
lindholm@CS.Stanford.EDU
Mon Dec 30 20:53:00 GMT 2002
The stringize and token-pasting operators seem to no longer work in the
"cpp" phases of compilation, but they worked in "cpp" in early versions of
gcc (2.95.3). I can't find it written that those operations must occur in
phases 1-4, but # and ## are "preprocessing-op-or-punc" and it would seem
that they should therefore be processed in phase 4.
Am I doing something wrong?
Using this example from the cpp info page:
#define COMMAND(NAME) { #NAME, NAME ## _command }
struct command commands[] =
{
COMMAND (quit),
COMMAND (help),
};
I get this as expected on an old version of cpp (2.95.3):
Xenon > cpp test2
# 1 "test2"
struct command commands[] =
{
{ "quit", quit_command } ,
{ "help", help_command } ,
};
and this on a new version of cpp (3.1):
thrush:~% cpp test2
# 1 "test2"
struct command commands[] =
{
{ #quit, quit ## _command },
{ #help, help ## _command },
};
More information about the Gcc
mailing list