我的 SNAP_LISTEN(...) 宏遇到了类似的问题(尽管在 C++ 中),定义如下。我找到的唯一解决方案是创建一个不包含 args... 参数的新宏 SNAP_LISTEN0(...)。在我的情况下,我没有看到另一种解决方案。-Wno-variadic-macros 命令行选项可防止可变参数警告,但不能防止 ISO C99 警告!
#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));
编辑:编译器版本
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.
编辑:命令行警告
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")
-Wno-variadic-macros 本身可以工作,因为我没有收到错误说不接受可变参数。但是,我得到与 Matt Joiner 相同的错误:
cpfs.c:232:33: warning: ISO C99 requires rest arguments to be used