pasting "." and "something" does not give a valid preprocessing token..

LLeweLLyn Reese llewelly@lifesupport.shutdown.com
Thu Apr 24 06:41:00 GMT 2003


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]



More information about the Gcc-help mailing list