[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc
Subject: Re: Possible bug in preprocessor
From: James Dennett <jdennett () acm ! org>
Date: 2007-03-31 4:24:44
Message-ID: euknqd$qh7$1 () sea ! gmane ! org
[Download RAW message or body]
JoseD wrote:
> Hi. Just wanted to share that the following macro gives an error on latest
> versions of GCC, but is reported to work on 2.95.3 (tested on MorphOS but
> should be the same for other OSses of course).
> Both an old version of SASC(AmigaOS) and Borland (on X86) worked fine.
>
> #include<stdio.h>
>
> #define EXTRACTBRCKTELMNT(Terminator, Elmnt) #Elmnt, #Terminator
>
> #define GETBRCKTELMNT(ToExtract) \
(added backslash above)
> GETELMNTEXPAND(EXTRACTBRCKTELMNT##ToExtract)
> #define GETELMNTEXPAND(a) GETELMNTEXPAND2 (a)
> #define GETELMNTEXPAND2(a, b) a, b
>
>
> int main (int argc, char **argv)
> { printf("%s %s\n", GETBRCKTELMNT((YYY, XXX)));
>
> getchar();
> return (0);
> }
My preprocessor agree that this is incorrect code and not a
g++ bug:
Error: Invalid use of ## token pasting operator, result is not a single
preprocessing token: "EXTRACTBRCKTELMNT(" from "EXTRACTBRCKTELMNT" and
"(" gives 2 tokens; this is undefined by 16.3.3/3
-- James
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic