* pasting "." and "something" does not give a valid preprocessing token..
@ 2003-04-24 6:29 mskhan
2003-04-24 6:41 ` LLeweLLyn Reese
0 siblings, 1 reply; 11+ messages in thread
From: mskhan @ 2003-04-24 6:29 UTC (permalink / raw)
To: gcc-help; +Cc: mskhan
I've just installed gcc 3.2 and I get the warning from the subject line when
compiling code that worked just fine with 2.95.3. Can anyone tell me what the
warning means and how it can be rectified.
The offending code is a macro :
#define EMUL_TRACE(level, format, args...) proc::theTrace->logTrace((level, ##format , ##args)
where "Proc" is a class defined as
class Proc
{
. ..........
static TraceLog * theTrace;
}
and TraceLog is another class defined as
class TraceLog
{
.............
public:
............
void logTrace(int severity, char* stringToBeLogged, ...)
.............
}
Thanks in advance....
Sanjay
"DISCLAIMER: This message is proprietary to Hughes Software Systems Limited
(HSS) and is intended solely for the use of the individual to whom it is
addressed. It may contain privileged or confidential information and
should not be circulated or used for any purpose other than for what it is
intended. If you have received this message in error, please notify the
originator immediately. If you are not the intended recipient, you are
notified that you are strictly prohibited from using, copying, altering, or
disclosing the contents of this message. HSS accepts no responsibility for
loss or damage arising from the use of the information transmitted by this
email including damage from virus."
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: pasting "." and "something" does not give a valid preprocessing token..
2003-04-24 6:29 pasting "." and "something" does not give a valid preprocessing token mskhan
@ 2003-04-24 6:41 ` LLeweLLyn Reese
0 siblings, 0 replies; 11+ messages in thread
From: LLeweLLyn Reese @ 2003-04-24 6:41 UTC (permalink / raw)
To: mskhan; +Cc: gcc-help
mskhan@hss.hns.com writes:
> I've just installed gcc 3.2 and I get the warning from the subject line when
> compiling code that worked just fine with 2.95.3. Can anyone tell me what the
> warning means and how it can be rectified.
>
> The offending code is a macro :
>
> #define EMUL_TRACE(level, format, args...) proc::theTrace->logTrace((level, ##format , ##args)
I think you do not want the token pasting ## before format or args.
#define EMUL_TRACE(level, format, args...) proc::theTrace->logTrace((level, format , args)
should do the trick.
The token-pasting operator is only for making tokens - 'foo##bar'
becomes the single token 'foobar' and its result must always
produce a single valid token (or the results are undefined). Your
examples would have pasted a comma onto the begining of a
multichar token, and , is only a valid token by itself.
>
>
> where "Proc" is a class defined as
>
> class Proc
> {
>
> . ..........
>
> static TraceLog * theTrace;
>
> }
>
> and TraceLog is another class defined as
>
> class TraceLog
> {
> .............
> public:
> ............
> void logTrace(int severity, char* stringToBeLogged, ...)
> .............
>
> }
>
[snip]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: pasting "." and "something" does not give a valid preprocessing token..
2003-08-19 8:35 ` Nathan Sidwell
@ 2003-08-19 9:12 ` Marc Eberhard
0 siblings, 0 replies; 11+ messages in thread
From: Marc Eberhard @ 2003-08-19 9:12 UTC (permalink / raw)
To: Nathan Sidwell; +Cc: gcc-help
Dear Nathan!
On Tue, Aug 19, 2003 at 09:35:18AM +0100, Nathan Sidwell wrote:
> Marc Eberhard wrote:
> > this-> ## v
> > mynamespace:: ## v
> >
> >Is there a way to convince the preprocessor, that I know, what I'm doing
> >and to accept the result as a vaild token (what it is in C++)? This is
> >with gcc (GCC) 3.3.1 20030626 (Debian prerelease).
> they are not valid single tokens. The preprocessor is correct. Why do you
> think you need a ## at all?
Ahhh, that's the solution. :-) I somehow thought, that I would have to use
## to combine the two and 2.95 happyly did the right thing with it. Only
when upgrading to 3.3 I suddenly ran into this problem. But you're perfectly
right... simply leaving the ## out solves the problem! Many thanks, I would
never have guessed, that the solution is that easy!!!
Thanks,
Marc
_______________________________________________________________________________
email: marc@greenie.net, marc.eberhard@alumni.tum.de, marc@affs.org.uk
email: m.a.eberhard@aston.ac.uk, web: http://www.aston.ac.uk/~eberhama/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: pasting "." and "something" does not give a valid preprocessing token..
2003-08-19 8:19 Marc Eberhard
@ 2003-08-19 8:35 ` Nathan Sidwell
2003-08-19 9:12 ` Marc Eberhard
0 siblings, 1 reply; 11+ messages in thread
From: Nathan Sidwell @ 2003-08-19 8:35 UTC (permalink / raw)
To: Marc Eberhard; +Cc: gcc-help
Marc Eberhard wrote:
> Dear LLeweLLyn Reese!
>
> You wrote:
>
>>The token-pasting operator is only for making tokens - 'foo##bar'
>> becomes the single token 'foobar' and its result must always
>> produce a single valid token (or the results are undefined). Your
>> examples would have pasted a comma onto the begining of a
>> multichar token, and , is only a valid token by itself.
>
>
> Ran into the same problem with a construct like this:
>
> this-> ## v
>
> If I change it to
>
> this->x ## v
>
> it works, but that's obviously not what I want. Same problem when
> constructing namespace defines like:
>
> mynamespace:: ## v
>
> Is there a way to convince the preprocessor, that I know, what I'm doing and
> to accept the result as a vaild token (what it is in C++)? This is with gcc
> (GCC) 3.3.1 20030626 (Debian prerelease).
they are not valid single tokens. The preprocessor is correct. Why do you think
you need a ## at all?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
The voices in my head said this was stupid too
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: pasting "." and "something" does not give a valid preprocessing token..
@ 2003-08-19 8:19 Marc Eberhard
2003-08-19 8:35 ` Nathan Sidwell
0 siblings, 1 reply; 11+ messages in thread
From: Marc Eberhard @ 2003-08-19 8:19 UTC (permalink / raw)
To: gcc-help
Dear LLeweLLyn Reese!
You wrote:
> The token-pasting operator is only for making tokens - 'foo##bar'
> becomes the single token 'foobar' and its result must always
> produce a single valid token (or the results are undefined). Your
> examples would have pasted a comma onto the begining of a
> multichar token, and , is only a valid token by itself.
Ran into the same problem with a construct like this:
this-> ## v
If I change it to
this->x ## v
it works, but that's obviously not what I want. Same problem when
constructing namespace defines like:
mynamespace:: ## v
Is there a way to convince the preprocessor, that I know, what I'm doing and
to accept the result as a vaild token (what it is in C++)? This is with gcc
(GCC) 3.3.1 20030626 (Debian prerelease).
Thanks,
Marc
_______________________________________________________________________________
email: marc@greenie.net, marc.eberhard@alumni.tum.de, marc@affs.org.uk
email: m.a.eberhard@aston.ac.uk, web: http://www.aston.ac.uk/~eberhama/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: pasting "." and "something" does not give a valid preprocessing token..
@ 2003-04-24 7:46 mskhan
0 siblings, 0 replies; 11+ messages in thread
From: mskhan @ 2003-04-24 7:46 UTC (permalink / raw)
To: LLeweLLyn Reese; +Cc: gcc-help
Hi Reese,
Thanks a lot for your reply. I have done as you had suggested.
However it has now started giving Parse Error wherever the macro is being
called.
The description of the error is as follows::
UIAProc.cpp: In member function `virtual void
UIAProc::UDPEventHandler(void*, int, const char*, int)':
UIAProc.cpp:275: parse error before `)' token
expecting o hear from you asap
thanks-
Sanjay
LLeweLLyn Reese <llewelly@lifesupport.shutdown.com> on 04/24/2003 12:07:55
PM
To: Mohammed Sanjay Khan/HSS@HSS
cc: gcc-help@gcc.gnu.org
Subject: Re: pasting "." and "something" does not give a valid
preprocessing token..
mskhan@hss.hns.com writes:
> I've just installed gcc 3.2 and I get the warning from the subject line
when
> compiling code that worked just fine with 2.95.3. Can anyone tell me what
the
> warning means and how it can be rectified.
>
> The offending code is a macro :
>
> #define EMUL_TRACE(level, format, args...)
proc::theTrace->logTrace((level, ##format , ##args)
I think you do not want the token pasting ## before format or args.
#define EMUL_TRACE(level, format, args...) proc::theTrace->logTrace((level,
format , args)
should do the trick.
The token-pasting operator is only for making tokens - 'foo##bar'
becomes the single token 'foobar' and its result must always
produce a single valid token (or the results are undefined). Your
examples would have pasted a comma onto the begining of a
multichar token, and , is only a valid token by itself.
>
>
> where "Proc" is a class defined as
>
> class Proc
> {
>
> . ..........
>
> static TraceLog * theTrace;
>
> }
>
> and TraceLog is another class defined as
>
> class TraceLog
> {
> .............
> public:
> ............
> void logTrace(int severity, char* stringToBeLogged, ...)
> {
> ......
> }
> .............
>
> }
>
[snip]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: pasting "." and "something" does not give a valid preprocessing token
2003-03-10 9:04 ` Momchil Velikov
@ 2003-03-10 9:08 ` Mihnea Balta
0 siblings, 0 replies; 11+ messages in thread
From: Mihnea Balta @ 2003-03-10 9:08 UTC (permalink / raw)
To: gcc-help
Oh, sorry. I thought it wouldn't work without ##. Obviously, I was wrong,
since i removed the ## and it works with no warnings.
Thanks.
On Monday 10 March 2003 11:02, Momchil Velikov wrote:
> >>>>> "Mihnea" == Mihnea Balta <dark_lkml@mymail.ro> writes:
>
> Mihnea> conf.##__prop
>
> conf.__prop is not a valid proprocessor token.
>
> Just remove the token paste operator.
>
> ~velco
>
> ------------------------------------------------------------------------
> http://felicitari.mymail.ro/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: pasting "." and "something" does not give a valid preprocessing token
2003-03-10 9:02 ` Mihnea Balta
@ 2003-03-10 9:05 ` Florian Weimer
0 siblings, 0 replies; 11+ messages in thread
From: Florian Weimer @ 2003-03-10 9:05 UTC (permalink / raw)
To: Mihnea Balta; +Cc: gcc-help
Mihnea Balta <dark_lkml@mymail.ro> writes:
> Sorry, I should have said "sv_port" instead of something in the subject line,
> as that is the exact warning produced. It doesn't like my conf.##__prop
> thing.
Maybe I'm missing something obvious, but why do you need the "##" in
this place at all?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: pasting "." and "something" does not give a valid preprocessing token
2003-03-10 8:59 Mihnea Balta
2003-03-10 9:02 ` Mihnea Balta
@ 2003-03-10 9:04 ` Momchil Velikov
2003-03-10 9:08 ` Mihnea Balta
1 sibling, 1 reply; 11+ messages in thread
From: Momchil Velikov @ 2003-03-10 9:04 UTC (permalink / raw)
To: Mihnea Balta; +Cc: gcc-help
>>>>> "Mihnea" == Mihnea Balta <dark_lkml@mymail.ro> writes:
Mihnea> conf.##__prop
conf.__prop is not a valid proprocessor token.
Just remove the token paste operator.
~velco
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: pasting "." and "something" does not give a valid preprocessing token
2003-03-10 8:59 Mihnea Balta
@ 2003-03-10 9:02 ` Mihnea Balta
2003-03-10 9:05 ` Florian Weimer
2003-03-10 9:04 ` Momchil Velikov
1 sibling, 1 reply; 11+ messages in thread
From: Mihnea Balta @ 2003-03-10 9:02 UTC (permalink / raw)
To: gcc-help
Sorry, I should have said "sv_port" instead of something in the subject line,
as that is the exact warning produced. It doesn't like my conf.##__prop
thing.
On Monday 10 March 2003 10:57, Mihnea Balta wrote:
> Hello,
>
> I've just installed gcc 3.2.2 and I get the warning from the subject line
> when compiling code that worked just fine with 2.95.3. The preprocessor
> output is what I expect it to be, but I'd like to know what the warning
> means. The offending code is:
>
> #define CONF_ADD_INT(__prop)
> \ if(!strncmp(key, #__prop, strlen(#__prop))){ \
> conf.##__prop = atoi(val); \
> return 1; \ }
>
> statement that produces the warning:
> CONF_ADD_INT(sv_port);
> The preprocessor output is exactly what I expected:
>
> if(!strncmp(key, "sv_port", strlen("sv_port"))){ conf.sv_port = atoi(val);
> return 1; };
>
> Thanks.
>
> ------------------------------------------------------------------------
> http://felicitari.mymail.ro/
^ permalink raw reply [flat|nested] 11+ messages in thread
* pasting "." and "something" does not give a valid preprocessing token
@ 2003-03-10 8:59 Mihnea Balta
2003-03-10 9:02 ` Mihnea Balta
2003-03-10 9:04 ` Momchil Velikov
0 siblings, 2 replies; 11+ messages in thread
From: Mihnea Balta @ 2003-03-10 8:59 UTC (permalink / raw)
To: gcc-help
Hello,
I've just installed gcc 3.2.2 and I get the warning from the subject line when
compiling code that worked just fine with 2.95.3. The preprocessor output is
what I expect it to be, but I'd like to know what the warning means.
The offending code is:
#define CONF_ADD_INT(__prop) \
if(!strncmp(key, #__prop, strlen(#__prop))){ \
conf.##__prop = atoi(val); \
return 1; \
}
statement that produces the warning:
CONF_ADD_INT(sv_port);
The preprocessor output is exactly what I expected:
if(!strncmp(key, "sv_port", strlen("sv_port"))){ conf.sv_port = atoi(val);
return 1; };
Thanks.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2003-08-19 9:12 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-24 6:29 pasting "." and "something" does not give a valid preprocessing token mskhan
2003-04-24 6:41 ` LLeweLLyn Reese
-- strict thread matches above, loose matches on Subject: below --
2003-08-19 8:19 Marc Eberhard
2003-08-19 8:35 ` Nathan Sidwell
2003-08-19 9:12 ` Marc Eberhard
2003-04-24 7:46 mskhan
2003-03-10 8:59 Mihnea Balta
2003-03-10 9:02 ` Mihnea Balta
2003-03-10 9:05 ` Florian Weimer
2003-03-10 9:04 ` Momchil Velikov
2003-03-10 9:08 ` Mihnea Balta
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).