我有一个类似的问题(虽然在C++中)与我的SNAP_LISTEN(...)宏定义如下。我找到的唯一解决方案是创建一个新的宏SNAP_LISTEN0(...),它不包含args ...参数。我没有看到我的情况下的另一个解决方案。 -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-可变参数的宏本身的工作,因为我没有得到一个错误,指出一个可变不被接受。然而,我得到了同样的错误作为马特乔伊纳:
cpfs.c:232:33: warning: ISO C99 requires rest arguments to be used
这让我困惑了很长一段时间。实际上标准的方法是'log_debug(“%s”,“重置位图”);'。 – Dummy00001 2010-07-31 15:50:29
预处理器省略号替代一个或多个参数有多奇怪,但C省略号替代零个或更多。我在从C99标准中提取这种语义时遇到了一些麻烦。 – 2012-11-23 02:19:53