如何识别gcc编译日志中的警告类型以禁用它? [英] How to identify a warning type in a gcc compile log to disable it?

查看:636
本文介绍了如何识别gcc编译日志中的警告类型以禁用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Eclipse CDT Indigo和g ++(Debian 4.9.2-10)4.9.2下编译我的项目时,我有很多警告。从这里,可能会解释一些Eclipse解析器错误,可能还有一些外部库bug。



当然我会升级Eclipse,但现在不能。



压制这些繁琐的警告。我阅读手册此处,但我仍然看不到以确定要设置哪些选项。我没有选中Eclipse中的 -Wall 选项,但没有任何更改。所有Eclipse警告现在都被禁用。



这是一个 pastbin

一个>我的编译日志。

解决方案

它看起来像吃了实际的警告线。至少在其中一行中,所有gcc警告都有警告字样。



编辑 实际上会产生类似的消息(注释行,从行需要,从行中实例化...,但没有实际的错误或警告行)。它看起来像gcc中有一个错误。 - 结束编辑。



在所有的gcc警告中,我只知道一个与超载有关的警告,并且具有列出候选功能的note子消息。警告显示:


C ++表示这些模糊不清,即使第一个最糟糕的转换比第二个最差的转换更好, / p>

,而且不能被关闭。如果你看到这样的警告,你的程序是不合规的,你应该修复它。



以下是这种不符合规范的代码示例。与功能签名相匹配:

  #include< string> 

struct KeyWord
{
KeyWord(const std :: string&);
运算符std :: string&()const;
};
$ b $ struct b

bool operator()(const std :: string&; const const std :: string&)const;
bool operator()(const KeyWord&;,const KeyWord&);
};

int main()
{
A a;
std :: string s;
const std :: string r;
a(s,r);

$ / code>

制作第二个运算符() const 解决了这个问题。


I have many warnings when I compile my project under Eclipse CDT Indigo and g++ (Debian 4.9.2-10) 4.9.2. From here, it may be explained by some Eclipse parser bugs, plus possibly some external library bugs.

I will upgrade Eclipse of course, but I cannot now.

I would like then to suppress these cumbersome warnings. I read the manual here, but still I don't see how to identify which options to set. I have unchecked the -Wall option in Eclipse, but nothing is changed. All Eclipse warnings are disabled now.

Here is a pastbin of my compile log.

解决方案

It looks like something ate your actual warning lines. All gcc warnings have the word "warning" in at least one of the lines.

EDIT Some builds of gcc actually produce similar messages ("note" lines, "required from" lines, "instantiated from" lines... but no actual "error" or "warning" line). It looks like there's a bug in gcc. — end edit.

Out of all gcc warnings, I know of only one that is related to overloading and has "note" submessages that lists candidate functions. The warning reads

C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second

and it cannot be turned off. If you see such warning, your program is non-compliant and you should fix it.

Here's an example of such non-compliant code. with function signatures matching yours:

#include <string>

struct KeyWord
{
    KeyWord(const std::string&);
    operator std::string&() const;
};

struct A
{
    bool operator() (const std::string&, const std::string&) const;
    bool operator() (const KeyWord&, const KeyWord&);
};

int main ()
{
    A a;
    std::string s;
    const std::string r;
    a(s, r);
}

Making the second operator() const solves the problem.

这篇关于如何识别gcc编译日志中的警告类型以禁用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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