* template expansion problem
@ 1998-04-26 10:28 Anthony Shipman
0 siblings, 0 replies; only message in thread
From: Anthony Shipman @ 1998-04-26 10:28 UTC (permalink / raw)
To: EGCS discussion list
This is with egcs 1.0.1 on Linux, Redhat 4.2.
I compile using:
g++ -pipe -gstabs -O0 -g -fno-implicit-templates -o x.o -c x.cc
g++ -pipe -gstabs -O0 -g -o x2.o -c x2.cc
g++ -pipe -gstabs -O0 -g -o x x.o x2.o
and I get
x.cc:13: undefined reference to `__hashtable_iterator<pair<char const *const,
int>, char const *, hash<char const *>, select1st<pair<char const *const, int>
>, equal_to<char const *>, __default_alloc_template<false, 0>
>::operator++(void)'
collect2: ld returned 1 exit status
The sources are shown below. Using nm, I see that x2.o contains the
constructor for the __hashtable_iterator instance but not the
operator++(void).
If I build x from x.cc using
g++ -pipe -gstabs -O0 -g -o x.o -c x.cc
g++ -pipe -gstabs -O0 -g -o x x.o
then it all works fine. nm on x.o shows the operator++.
x.cc
----------------------------------
#include <hash_map.h>
typedef hash_map<const char*, int> MyMap;
int
main()
{
MyMap map;
map["abc"] = 3;
map["fred"] = 42;
for(MyMap::iterator iter = map.begin();
iter != map.end();
iter++)
{
cout << "mymap[" << iter->first << "] = " << iter->second << endl;
}
return 0;
}
x2.cc
-----------------------------------
#include <hash_map.h>
template class hash_map<const char*, int>;
--
Anthony Shipman "You've got to be taught before it's too late,
TUSC Computer Systems Pty Ltd Before you are six or seven or eight,
666 Doncaster Rd, Doncaster To hate all the people your relatives hate,
Melbourne, Australia, 3108 You've got to be carefully taught." R&H
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1998-04-26 10:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-04-26 10:28 template expansion problem Anthony Shipman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).