Search code examples
cgccc99variadic

What does this compiler warning generated by `-pedantic` mean?


What does this GCC warning mean?

cpfs.c:232:33: warning: ISO C99 requires rest arguments to be used

The relevant lines are:

__attribute__((format(printf, 2, 3)))
static void cpfs_log(log_t level, char const *fmt, ...);

#define log_debug(fmt, ...) cpfs_log(DEBUG, fmt, ##__VA_ARGS__)

log_debug("Resetting bitmap");

The last line being line 232 inside a function implementation. The compiler flags are:

-g -Wall -std=gnu99 -Wfloat-equal -Wuninitialized -Winit-self -pedantic

Solution

  • Yes it means that you have to pass at least two arguments the way that you defined it. You could just do

    #define log_debug(...) cpfs_log(DEBUG, __VA_ARGS__)
    

    and then you'd also avoid the gcc extension of the , ## construct.