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?
My answer is not as cool as a patch. If you want a less verbose error message, this script will remove the ugly code, and just leave the line number for the candidates.
So, it can be used in a script like this:
If the name of this script is
g++
and in your path, it should work as if you have added a command line option called-fterse-notes
.Does
-Wfatal-errors
do what you want?It stops all errors after the first one, which is not the same as simply suppressing the candidate function notes, but it reduces the output significantly:
Or, if you wanted to patch GCC, this adds a
-fno-candidate-functions
switch:As far as I know, there is no compilation flag in GCC to disable the suggested candidates in case of ambiguous function calls.
Your only hope is perhaps to patch the GCC source code.
Digging in it (version: 4.7.1), I've found what appear to be the relevant function in
gcc/cp/pt.c
:As an educated guess, I think that you only need to comment out the function body.