This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Change in preprocessor behavior
- From: Neil Booth <neil at daikokuya dot co dot uk>
- To: Stephen Lindholm <lindholm at CS dot Stanford dot EDU>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 30 Dec 2002 22:46:41 +0000
- Subject: Re: Change in preprocessor behavior
- References: <Pine.GSO.4.21.0212301419040.17036-100000@Xenon.Stanford.EDU>
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 },
};
$