I'm using this simple macro for logging events of my program:
#define _ERROR(format, args...)  \
    { \
    time_t t = time(0);\
    struct tm * now = localtime( & t );\
    fprintf(stderr, "[ERROR %d-%d-%d %d:%d:%d]: ",now->tm_year + 1900,\
            now->tm_mon + 1, now->tm_mday,\
            now->tm_hour, now->tm_min, now->tm_sec); \
    fprintf(stderr, format , ## args);\
    printf("\n");\
    fflush(stderr);\
    }
It compiles happily on Linux and Windows using GCC and MinGW. Though MSVC 11 fails to compile.
Note: I'm experiencing difficulties understanding this and this answers on previous SO questions. I think I'm missing something about macros and/or variadic argument count. So:
- What is __VA_ARGS__? Do I have to use it?
- Do I have to use it only for MSVC-compilable code?
- Is above code wrong / none-standard / inelegant because of lack of those __VA_ARGS__staff?
 
    