This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Preprocessor macro question



Hi folks,

I looked around in the archives but couldn't find a conclusive answer to
my question.  I have the following macro defined:

#ifdef _J_DEBUG_
#define debugDump(format, ...) \
   fprintf(stderr, "%s:%d> ", __FILE__, __LINE__); \
   fprintf(stderr, format, ##__VA_ARGS__ )
#else
#define debugDump(format, ...)
#endif

And I'm defining _J_DEBUG_ at compile time.  Now in a file called cmd.c
I have the following:

17   debugDump("not a command node");
18   !xmlnode->name ?
19      debugDump("xmlnode->name == NULL\n") :
20      debugDump("xmlnode->name == \"%s\"\n", "foo") ;

And when I compile I see this:

cmd.c:20:54: warning: pasting would not give a valid preprocessing token
cmd.c:25:67: warning: pasting would not give a valid preprocessing token
cmd.c: In function `addCommand':
cmd.c:19: parse error before `;'
cmd.c:19: parse error before `:'
make: *** [cmd-d] Error 1

So here's my question.  Have I done something particularly wrong, or is
this related to a bug back in September 2000 discussed in the thread at
http://gcc.gnu.org/ml/gcc/2000-09/msg00138.html by Zack Weinberg among
others?  I suspect it is since I'm currently using gcc 2.96 (from a Red
Hat 7.0 install through no fault of my own. ;-) ) but before I start
asking for folks on the team to upgrade the compiler, I'd like some
advice.

Thanks,
-Joe.

-- 
Joe MacDonald
:wq


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]