public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: preprocessor/9689: Number: 9688 update : pasting "<" and "ValidStruct" does not give a valid preprocessing token
@ 2003-02-13 17:06 Zack Weinberg
0 siblings, 0 replies; 3+ messages in thread
From: Zack Weinberg @ 2003-02-13 17:06 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR preprocessor/9689; it has been noted by GNATS.
From: Zack Weinberg <zack@codesourcery.com>
To: ediaz@veridis.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: preprocessor/9689: Number: 9688 update : pasting "<" and
"ValidStruct" does not give a valid preprocessing token
Date: Thu, 13 Feb 2003 08:56:00 -0800
ediaz@veridis.com writes:
>
> #define CM(x) \
> template<> \
> class C < ##x > \
This is a shining example of a totally unnecessary use of ##. Just
remove it and your code will work.
zw
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: preprocessor/9689: Number: 9688 update : pasting "<" and "ValidStruct" does not give a valid preprocessing token
@ 2003-02-13 10:12 neil
0 siblings, 0 replies; 3+ messages in thread
From: neil @ 2003-02-13 10:12 UTC (permalink / raw)
To: ediaz, gcc-bugs, gcc-prs, nobody
Synopsis: Number: 9688 update : pasting "<" and "ValidStruct" does not give a valid preprocessing token
State-Changed-From-To: open->closed
State-Changed-By: neil
State-Changed-When: Thu Feb 13 10:12:49 2003
State-Changed-Why:
Not a bug.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9689
^ permalink raw reply [flat|nested] 3+ messages in thread
* preprocessor/9689: Number: 9688 update : pasting "<" and "ValidStruct" does not give a valid preprocessing token
@ 2003-02-13 10:06 ediaz
0 siblings, 0 replies; 3+ messages in thread
From: ediaz @ 2003-02-13 10:06 UTC (permalink / raw)
To: gcc-gnats
>Number: 9689
>Category: preprocessor
>Synopsis: Number: 9688 update : pasting "<" and "ValidStruct" does not give a valid preprocessing token
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Thu Feb 13 10:06:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: ediaz@veridis.com
>Release: g++ (GCC) 3.3 20030212 (prerelease)
>Organization:
>Environment:
SuSE 7.3/Linux
>Description:
c&p of the #9688 descripton :
When I try to compile a file using macros of templates, I get a 'MyFileStruct.h:541:67: pasting "<" and "MyStruct" does not give a valid preprocessing token' message.
It worked perfectly with the 2.95.x serie and with the 3.2.1 version.
I've tryied to do it in two passes, with a --save-temps and a g++ thefile.ii -c and it worked. Like if the processed code was not the same as the preprocessor's output.
-----------
I've made a better & cleaner example and attached it :
>How-To-Repeat:
Explanations in test2.cpp
>Fix:
Use the two passes trick.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="test2.cpp"
Content-Disposition: inline; filename="test2.cpp"
/*
This is a better example of the problem (cleaner too)
How to fail :
sh-2.05$ g++ test2.cpp -o test2_fail
test2.cpp:46:11: pasting "<" and "Field" does not give a valid preprocessing token
How to success :
sh-2.05$ g++ test2.cpp --save-temps
test2.cpp:46:11: pasting "<" and "Field" does not give a valid preprocessing token
sh-2.05$ g++ test2.ii -o test2_success
sh-2.05$
I hope it will helps.
Regards,
Eric Diaz
*/
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
template <class T>
class C
{
T hold;
public:
C(T to_hold)
{
hold=to_hold;
}
static void process(T a_value)
{
puts("Generic");
return 0;
}
};
#define CM(x) \
template<> \
class C < ##x > \
{ \
public: \
static void process(x a_value) \
{ \
puts("Not Generic (" #x ")"); \
} \
};
struct Field
{
};
struct Field2
{
};
// The following will fail :
CM( Field )
// The following, being a copy&paste of the .ii output for the CM( Field ) (with Field replaced by Field2) will work.
template<> class C < Field2 > { public: static void process(Field2 a_value) { puts("Not Generic (" "Field2" ")"); } };
int main(int argc,char* argv[])
{
Field f1;
Field2 f2;
C<Field>::process(f1);
C<Field2>::process(f2);
return 0;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-02-13 17:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-13 17:06 preprocessor/9689: Number: 9688 update : pasting "<" and "ValidStruct" does not give a valid preprocessing token Zack Weinberg
-- strict thread matches above, loose matches on Subject: below --
2003-02-13 10:12 neil
2003-02-13 10:06 ediaz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).