This topic is now archived and is closed to further replies.


macros, with variable amounts of arguments

Recommended Posts

OK, I have a problem I''m trying to solve via macros. If there''s a better way let me know (after you''ve heard the problem). I''m trying to write some debugging routines that I only want to be compiled during debugging (suprisingly enough). I also wanted them to be flexible enough to provide whatever information I needed to output for a particular error (hence variable number of arguments). Further to this, I wanted them to automatically embed the line and file the error occured at. So I have my function, something like: int Error(int line, char *file, char *msg, ...); My ideal macro would be: #define ERROR(__LINE__, __FILE__, message, ...) But the compiler doesn''t like the ellipses. I''ve tried a bunch of ways to get this to work but nothing has been successful. I found some GCC documentation about variadic macros (just a search on Google found this) which appears to do what I want. However, VC++ 6 doesn''t seem to support it. Any ideas (short of switching to GCC) or alternative solutions would be welcome. Thanks, -Mezz

Share this post

Link to post
Share on other sites