M
Michael B Allen
Is the following legit?
#define PRINT(err, fmt, ...) \
my_printf(__FILE__ ": %s" fmt, errstr(err), ##__VA_ARGS__)
Without the ## if I call this like PRINT(EFOO, ": foo!") this reduces
to following invalid function call:
my_printf("file.c" ": %s" ": foo!", errstr(err),)
But with gcc at least the ## ensures the trailing comma is removed if
no rest arguments are provided. Is this gcc specific is it valid C99?
Thanks,
Mike
#define PRINT(err, fmt, ...) \
my_printf(__FILE__ ": %s" fmt, errstr(err), ##__VA_ARGS__)
Without the ## if I call this like PRINT(EFOO, ": foo!") this reduces
to following invalid function call:
my_printf("file.c" ": %s" ": foo!", errstr(err),)
But with gcc at least the ## ensures the trailing comma is removed if
no rest arguments are provided. Is this gcc specific is it valid C99?
Thanks,
Mike