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.
While people competing in the
IOCCC have made C preprocessors do amazing things, the normal usage of variable args macros doesn't have the muscle to handle this problem. You can do it as a function because you can program the function to detect the end of the arg list in a manner you specify then wrap it in a macro if you want to. I have rearranged your parameters to place a zero at the end which code yet to be written could detect.
MACRO_TEST(4,count,HEX,8,test,CHAR,0);
Unfortunately your macro does little more than printf() already does. Perhaps printf() could fill the bill.
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").
It is not created as a string. It is the list of arguments in compilable form. You can make __VA_ARGS__ a string with the # macro stringize operator as shown in the Pelles-C help. Search the Index for "C Preprocessor" then click on #define.