This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Change in preprocessor behavior


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 },
};



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]