Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c

gcc

variadic

c99

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
like image 650
Matt Joiner Avatar asked Jul 31 '10 14:07

Matt Joiner


1 Answers

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.

like image 88
Jens Gustedt Avatar answered Sep 17 '22 13:09

Jens Gustedt