C++ err msgs
Nathan Myers
ncm@cantrip.org
Thu May 11 01:52:00 GMT 2000
On Thu, May 11, 2000 at 12:56:11AM +0200, Gabriel Dos Reis wrote:
> Under what
> circumstances default template arguments should be displayed isn't
> that obvious. Any suggestion is welcome.
This seems very easy to me. *Never* display default template arguments.
The type is uniquely determined by the non-default arguments, so those
are the only ones to display. The default bindings are part of the
definition, and may easily be looked up in the header file by anyone
interested. I can't even imagine a plausible counter-argument.
However, to implement this for linker messages probably requires some
compiler help, such as an asm equate of the longer actual symbol to
the squangled shortened form (the latter perhaps prefixed to identify
it as such).
Namespace qualifiers on argument types should also be omitted where
they match the namespace of the function itself. Thus:
ring.tcc:54: multiple definition of `std::basic_string<char>::basic_string(
unsigned, char, allocator<char> const&)
Note that I have changed "unsigned int" to "unsigned"; only pedantry
insists on "unsigned int". The "(" is directly adjacent to the function
name, according to universal industry convention. The indentation
doesn't try to line up the "unsigned" with the "(" because that is
rarely practical for C++.
I don't think there's any point in putting in code to insert a space
into ``>>'' in template-argument-list terminator sequences. ``>>''
appearing in a type name emitted in an error message can mean the
operator lexeme only if it appears after the keyword ``operator'',
so there can be no ambiguity.
Making the format depend on environment variables strikes me as
wishy-washy. Make the messages as short, clear, and readable as
you can make them. Please don't worry about Gnuical-correctness
where it conflicts with that, except to the extent that Emacs needs
in order to find the correct line in the source file.
I will join Benjamin by sending you a bottle of fine Pinot Noir if
you implement something even vaguely like this; two bottles if you
can shorten linker messages too.
Nathan Myers
ncm at cantrip dot org
More information about the Libstdc++
mailing list