Execution of some mocro definition yield unexpected results: "cpp" reports: > > cpp-define.c:22:13 warning: pasting ")" and "l" > does not give a valid preprocessing token > Release: gcc version 3.1 Environment: HPUX 10.20 hw:K460, HPUX 11.00 hw:J5000, GNU/Linux Debian 2.2.17 How-To-Repeat: "cpp-define.c" is the attached file gcc -E cpp cpp-define.c cpp cpp-define.c
Fix: I do not know.
State-Changed-From-To: open->closed State-Changed-Why: Not a bug. You have a ## in your macro definition that is being used to create a token from ")" and "l" by concatenation. No such token exists. You can probably remove the ## in question.
State-Changed-From-To: closed->open State-Changed-Why: Sorry, ignore previous message. I'll look at this later.
State-Changed-From-To: open->closed State-Changed-Why: Not a bug. #define __CONCAT__(_A,_B) _A ## _B #define __CONCAT_U__(_A) _A ## u #define UINT32_C(__c) __CONCAT__(__CONCAT_U__(__c),l) UINT32_C(123) The bug in your macro occurs during the expansion of UINT32_C. Since, in the definition of __CONCAT__, the first argument is operated on by ##, it is not expanded before replacement. Therefore, the first stage of expansion is UINT32_C(123) __CONCAT__(__CONCAT_U__(123),l) __CONCAT_U__(123)##l which is not what you want, and gives rise to the (correct) warning you see. You want the argument to be expanded, and so you need an extra level of indirection: #define __CONCAT_INDIRECT(_A,_B) __CONCAT(_A,_B) #define __CONCAT__(_A,_B) _A ## _B #define __CONCAT_U__(_A) _A ## u #define UINT32_C(__c) _CONCAT_INDIRECT__(__CONCAT_U__(__c),l) UINT32_C(123) If HPUX AnsiC gives the answer you wanted, then it's simply not ANSI 8-) Neil.
From: Andreas Schwab <schwab@suse.de> To: neil@gcc.gnu.org Cc: gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, stoppel@immt.pwr.wroc.pl, gcc-gnats@gcc.gnu.org Subject: Re: preprocessor/7976: macro definition Date: Thu, 19 Sep 2002 15:45:21 +0200 neil@gcc.gnu.org writes: |> Synopsis: macro definition |> |> State-Changed-From-To: closed->open |> State-Changed-By: neil |> State-Changed-When: Thu Sep 19 06:13:38 2002 |> State-Changed-Why: |> Sorry, ignore previous message. I'll look at this later. IMHO your previous analysis was right. UINT32_C(123) -> __CONCAT__(__CONCAT_U__(123),l) -> __CONCAT_U__(123) ## l and )l is not a token. This needs to be written like this: #define __CONCAT2__(_A,_B) _A ## _B #define __CONCAT__(_A,_B) __CONCAT2__(_A,_B) #define __CONCAT_U__(_A) _A ## u #define UINT32_C(__c) __CONCAT__(__CONCAT_U__(__c),l) Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
*** Bug 17299 has been marked as a duplicate of this bug. ***
*** Bug 16275 has been marked as a duplicate of this bug. ***
*** Bug 12513 has been marked as a duplicate of this bug. ***
*** Bug 9689 has been marked as a duplicate of this bug. ***
Reopening to mark as ...
Not a bug.
*** Bug 17304 has been marked as a duplicate of this bug. ***
*** Bug 24098 has been marked as a duplicate of this bug. ***
*** Bug 17638 has been marked as a duplicate of this bug. ***
*** Bug 12607 has been marked as a duplicate of this bug. ***
Subject: AW: macro definition Stopp blaming us!!! Remove us immediatelly from cc List. Thx! -----Ursprüngliche Nachricht----- Von: pinskia at gcc dot gnu dot org [mailto:gcc-bugzilla@gcc.gnu.org] Gesendet: Mittwoch, 28. September 2005 06:06 An: planta Betreff: [Bug preprocessor/7976] macro definition ------- Additional Comments From pinskia at gcc dot gnu dot org 2005-09-28 04:05 ------- *** Bug 12607 has been marked as a duplicate of this bug. ***
As requested in comment #17
*** Bug 25170 has been marked as a duplicate of this bug. ***