如何在 gcc 编译日志中识别警告类型以禁用它?

How to identify a warning type in a gcc compile log to disable it?

当我在 Eclipse CDT Indigo 和 g++ (Debian 4.9.2-10) 4.9.2 下编译我的项目时,我有很多警告。从 here 开始,它可能是由一些 Eclipse 解析器错误以及可能的一些外部库错误解释的。

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

然后我想取消这些繁琐的警告。我阅读了手册 here,但仍然不知道如何确定要设置的选项。我取消选中 Eclipse 中的 -Wall 选项,但没有任何改变。现在禁用所有 Eclipse 警告。

这是我的编译日志的pastbin

看起来好像有什么东西吃了你的实际警告线。所有 gcc 警告至少在其中一行中包含单词 "warning"。

编辑 gcc 的某些版本实际上会产生类似的消息("note" 行、"required from" 行、"instantiated from" 行。 .. 但没有实际的 "error" 或 "warning" 行)。看起来 gcc 中有一个错误。 — 结束编辑。

在所有 gcc 警告中,我只知道一个与重载有关并且有 "note" 个列出候选函数的子消息。警告内容为

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

并且无法关闭。如果你看到这样的警告,你的程序是不兼容的,你应该修复它。

这是此类不合规代码的示例。具有与您匹配的函数签名:

#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);
}

使第二个 operator() const 解决问题。