用于零可变宏参数的GCC编译器警告标志
GCC中零可变参数的编译器警告标志是什么(我使用GCC 5.3.0)?
What is the compiler warning flag for zero variadic macro arguments in GCC (I am using GCC 5.3.0)?
警告是由这样的代码触发
The warning is triggered by code like this
// for illustration purposes only:
int foo(int i) { return 0; };
#define FOO(A, ...) foo(A, ##__VA_ARGS__)
FOO(1);
^ warning: ISO C++11 requires at least one argument for the "..." in a variadic macro
,但警告不指示哪个标志用于启用/禁用警告(这通常显示在方括号 [ - Wwarning-flag-name]
)。
but the warning doesn't indicate which flag is used to enable/disable the warning (this is typically shown in square brackets [-Wwarning-flag-name]
).
在clang中,它是 -Wgnu-zero-variadic-macro-arguments
。我在中找不到任何类似的内容
In clang it is -Wgnu-zero-variadic-macro-arguments
. I haven't been able to find anything like that in the warning documentation of gcc-5.3.0.
我尝试了 -Wgnu-zero-variadic-macro-arguments
I've tried -Wgnu-zero-variadic-macro-arguments
, -Wvarargs
, -Wno-variadic-macros
(thanks to @ Revolver_Ocelot) but none of these is in charge of this warning.
导致问题的警告标志是 -Wpedantic
。这是因为省略可变参数是非法的,它需要诊断。警告符合该要求。
The warning flag that is causing the issue is -Wpedantic
. This is because omitting variadic arguments is illegal and it requires a diagnostic. A warning satisfies that requirement.