禁用 g++“注意候选项是.."编译器消息

Disable g++ quot;note candidates are..quot; compiler message(禁用 g++“注意候选项是..编译器消息)

本文介绍了禁用 g++“注意候选项是.."编译器消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很多时候,当我编译有错字或其他类型不匹配的东西时,我会收到标准的错误:'functionname' in ..."错误.这很棒.然后,特别是在函数和运算符重载的情况下,g++ 继续列出 10 页的候选列表,它们只是可怕的海量模板定义.

Many times when I compile something with a typo or some other typing mismatch, I get the standard "error: no match for 'functionname' in ..." error. This is great. Then, especially in the case of overloaded functions and operators, g++ goes on and list like 10 pages of candidates which are just hideous and massive template definitions.

错误信息很好,但是有什么方法可以禁止它提示其他功能变体?

The error message is great, but is there any way to disable it from suggesting other functions variants?

推荐答案

据我所知,GCC 中没有编译标志可以在函数调用不明确的情况下禁用建议的候选.

As far as I know, there is no compilation flag in GCC to disable the suggested candidates in case of ambiguous function calls.

您唯一的希望可能是修补 GCC 源代码.

Your only hope is perhaps to patch the GCC source code.

深入研究(版本:4.7.1),我发现 gcc/cp/pt.c 中似乎是相关函数:p>

Digging in it (version: 4.7.1), I've found what appear to be the relevant function in gcc/cp/pt.c:

void
print_candidates(tree fns)
{
  const char *str = NULL;
  print_candidates_1 (fns, false, &str);
  gcc_assert (str == NULL);
}

作为一个有根据的猜测,我认为您只需要注释掉函数体.

As an educated guess, I think that you only need to comment out the function body.

这篇关于禁用 g++“注意候选项是.."编译器消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:禁用 g++“注意候选项是.."编译器消息

基础教程推荐