我有一個類似的問題(雖然在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