C++ err msgs [ was Re: building libstdc++-v3 from the 20000105 snapshot dies with multiple def errors. ]

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Wed May 10 14:08:00 GMT 2000


> off topic or not, I think it is an interesting feature for new users. I am
> not a new one (not very old too ;) but sometimes I would like to have 
> error message with my own typedefs.

There is machinery in g++ to do that. If you have test cases that show
that it does not work, they would be much appreciated - especially
when they are "simple" test cases.

The problem is that there is a function in the compiler that looks
"through" a typedef, and when the compiler continues to use the result
of that lookup instead of the original typedef, you get that kind of
errors.

Of course, if the compiler did not even have a the typedef in the
original context, it won't help at all. There is no attempt to find a
"matching" typedef for error messages, given the expanded type. That
may be confusing, especially as you may get a typedef you've never
used yourself:

namespace SomeStrangeLibrary{
  typedef vector<int> ListOfRandomKeys;
}
//... much later ...
int main(){
  vector<int> numbers;
  numbers.pash_back(4);
}

no matching function for call to `SomeStrangeLibrary::ListOfRandomKeys::pash_back (int)'

is probably *not* what you want. Given

#include <vector>

typedef vector<int> foo;

int main()
{
  foo numbers;
  numbers.pash_back(4);
}

egcs 1.1.2 would say

a.cc: In function `int main()':
a.cc:8: no matching function for call to `foo::pash_back (int)'

Regards,
Martin


More information about the Libstdc++ mailing list