egcs-1.1.2 template explicit instantiation problems (Was: wstring ...)

Steinar Bang sb@metis.no
Fri Feb 11 05:46:00 GMT 2000


>>>>> Alexandre Oliva <oliva@lsd.ic.unicamp.br>:

> On Feb 11, 2000, Steinar Bang <sb@metis.no> wrote:
>> wchar_t* string_char_traits<wchar_t>::move(wchar_t *, wchar_t const *, unsigned int);

>> /home/sb/2x/lib/libmetis_tools.so: undefined reference to `string_char_traits<wchar_t>::move(wchar_t *, wchar_t const *, unsigned int)'

>> Presumably there is something wrong with my explicit instantiation
>> syntax?

> Yup.  Explicit instantiations must be preceded by the keyword
> `template':

> template wchar_t* string_char_traits<wchar_t>::move(wchar_t *, wchar_t const *, unsigned int);

I tried that at first, but that gave me a syntax error in egcs-1.1.2.

What I've done now is to add -O1 to the debug flags, and compile for
debug using -g -O1 (while non-debug optimization is -O2).

This seems to instantiate the neccessary missing symbols (or
whatever).

I determined that -O1 was enough by using:
 g++ -c wstringtest.cpp
 g++ -o wstringtest wstringtest.o
which gave me linking problems, and
 g++ -c -O1 wstringtest.cpp
 g++ -o wstringtest wstringtest.o
which linked OK.

The wstringtest.cpp program looked like this:

#include <string>

main(int, char**)
{
    wstring str = L"Hello World!";
}


More information about the Gcc mailing list