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 l开发者_如何学JAVAog_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
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.
It means that you are not passing a second argument to log_debug. It's expecting one or more arguments for the ...
part, but you're passing zero.
I am having a similar problem (although in C++) with my SNAP_LISTEN(...) macro as defined below. The only solution I have found is to create a new macro SNAP_LISTEN0(...) which does not include the args... parameter. I do not see another solution in my case. The -Wno-variadic-macros command line option prevents the variadic warning but not the ISO C99 one!
#define SNAP_LISTEN(name, emitter_name, emitter_class, signal, args...) \
if(::snap::plugins::exists(emitter_name)) \
emitter_class::instance()->signal_listen_##signal( \
boost::bind(&name::on_##signal, this, ##args));
#define SNAP_LISTEN0(name, emitter_name, emitter_class, signal) \
if(::snap::plugins::exists(emitter_name)) \
emitter_class::instance()->signal_listen_##signal( \
boost::bind(&name::on_##signal, this));
Edit: compiler version
g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Edit: command line warnings
set(CMAKE_CXX_FLAGS "-Werror -Wall -Wextra -pedantic -std=c++0x
-Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization
-Wformat=2 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wnoexcept
-Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow
-Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default
-Wundef -Wno-unused -Wno-variadic-macros -Wno-parentheses
-fdiagnostics-show-option")
The -Wno-variadic-macros itself works since I do not get an error saying that the variadic is not accepted. However, I get the same error as Matt Joiner:
cpfs.c:232:33: warning: ISO C99 requires rest arguments to be used
精彩评论