I may be in the wrong place but if this needs to be moved...
I want to write a macro with a variable number of arguments (4-?) something like
MACRO_TEST(VAR,count,4,HEX,test,8,CHAR) etc. This would cause something like count=0x0000 test="Eureka!" to be printed in a logging file I am building. The variable name, length and type of printing to be done could be repeated as many times as necessary.
I have done a few searches on the web and found that __VA_ARGS__ appears to allow you to create a macro with a variable number of arguments as a string ("count,4,HEX,test,8,CHAR"). This is an ISO C99 Standard that Pelles C appears to support with the caution that "(for stuff listed as "supported" it sometimes just mean "accept the new syntax" without doing much else)".
I tried compiling the following macro:
270 #define SQLLIB_TEST(dumpRecd,...) \
271 fprintf(stdout,"%s\n",dumpRecd); \
272 fprintf(stdout,"test\n"); \
273 fprintf(stdout,"%s",__VA_ARGS__);
and all I get from the compile is the message "C:\My_C_Library\Include\mysqllib_client.h(270): error #1049: Syntax error in macro parameters."
Is the use of the __VA_ARGS__ macro "exploited" in Pelles C (I.E Full support for variable macros)?
If so where could I find a working example with __VA_ARGS__?
If not, any thoughts on how I could accomplish my goal via some other method (variable argument functions???) are greatly appreciated....
THANKS!