用于零可变宏参数的GCC编译器警告标志 [英] GCC compiler warning flag for zero variadic macro arguments

查看:834
本文介绍了用于零可变宏参数的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.

这篇关于用于零可变宏参数的GCC编译器警告标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆