Variable Argument Macros

When the C99 extensions setting is on, the compiler allows macros to have a variable number of arguments. Variable argument macros example shows an example.

Listing 1. Variable argument macros example
#define MYLOG(...) fprintf(myfile, __VA_ARGS__)
#define MYVERSION 1
#define MYNAME "SockSorter"

int main(void)
{
    MYLOG("%d %s\n", MYVERSION, MYNAME);
    /* Expands to: fprintf(myfile, "%d %s\n", 1, "SockSorter"); */

    return 0;

}