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]

Re: Change in preprocessor behavior


Stephen Lindholm wrote:-

> 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 },
> };
 
I can't reproduce this.  In fact, I don't believe you're using GCC 3.1,
since the output would be more like that below (note the <built-in>
etc.).

FWIW I am confident there are no bugs in # and ## handling in GCC 3.1
and later.

Neil.
 

$ cpp --version
cpp (GCC) 3.1.1 20020721 (prerelease)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

$ cpp /tmp/bug.c
# 1 "/tmp/bug.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "/tmp/bug.c"


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]