Hi, I have a piece of code as pasted below. I get warnings like test1.c:29:32: warning: pasting "(" and ""ERROR:"" does not give a valid preprocessing token test1.c: In function `main': test1.c:29: `__MODULE__' undeclared (first use in this function) test1.c:29: (Each undeclared identifier is reported only once test1.c:29: for each function it appears in.) What does warning: pasting "(" and ""ERROR:"" does not give a valid preprocessing token mean? And where is __MODULE__ defined? Please provide me some solution. Thanks, Taklu. -------------------------------------------------------- Code: #include <stdio.h> #include <stdarg.h> #define DL1 "%s:" #define DR1 ,__MODULE__ #define DL2 "%d:" #define DR2 ,__LINE__ void Trace(char *format, ...); #define Debug(ARGS...) Trace(##ARGS) #define Error(ARGS,...) \ Debug("ERROR:"DL1 DL2 ARGS "\n" DR1 DR2, ## __VA_ARGS__) void Trace(char *format, ...){ va_list args; va_start(args, format); vprintf(format, args); va_end(args); return; } main(){ int i = 10; Error("Print from main"); return 0; }
Well there's some serious preprocessor abuse going on here... You define Debug() as Trace, then Error as Debug, so Error is actually being defined as Trace(). When you use the ## pasting token, you need to provide two tokens to paste together, so Trace (##ARGS) makes no sense, and neither does DR2, ##__VA_ARGS__ a few lines later. So possibly this is old code that worked on older compilers and needs fixing up for new compilers. __MODULE__ and __LINE__ are defined by the preprocessor; __MODULE__ is the filename and __LINE__ is the current line number.