This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Static members in templates in egcs-1.0.1
- To: egcs at cygnus dot com
- Subject: Static members in templates in egcs-1.0.1
- From: Erik Corry <erik at arbat dot com>
- Date: Tue, 13 Jan 1998 00:39:40 +0100
Hi,
I obtained egcs-1.0.1 and compiled it with the naive
./configure
make
make install
on my i586-pc-linux-gnu system with glibc-2.0.5c-10, gcc-2.7.2.3-8
and binutils-2.8.1.0.1-1 installed. It seems I can now use
egcs as /usr/local/bin/gcc, which is cool.
But it seems that static members of templates still don't work:
template <class T>
struct B
{
static T mycounter = 0; // with static - doesn't work with egcs
//T mycounter; // without static - works with egcs
void IncCounter() {mycounter++;}
};
int
main()
{
B<int> a;
a.IncCounter();
return 0;
}
when I compile with
/usr/local/bin/gcc -o smt static_simple.cpp
I get
/tmp/cca283291.o: In function `B<int>::IncCounter(void)':
/tmp/cca283291.o(.B<int>::gnu.linkonce.t.IncCounter(void)+0x8): undefined reference to `B<int>::mycounter'
with -v, that's
Reading specs from /usr/local/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.90.23/specs
gcc version egcs-2.90.23 980102 (egcs-1.0.1 release)
/usr/local/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.90.23/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=90 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem(posix) -D__EXCEPTIONS -Di386 -Di586 -Asystem(unix) -Acpu(i386) -Amachine(i386) -D__i386__ -D__i586__ -Asystem(unix) -Acpu(i386) -Amachine(i386) static_simple.cpp /tmp/cca28614.ii
GNU CPP version egcs-2.90.23 980102 (egcs-1.0.1 release) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/local/i586-pc-linux-gnu/include
/usr/local/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.90.23/include
/usr/include
End of search list.
/usr/local/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.90.23/cc1plus /tmp/cca28614.ii -quiet -dumpbase static_simple.cc -version -o /tmp/cca28614.s
GNU C++ version egcs-2.90.23 980102 (egcs-1.0.1 release) (i586-pc-linux-gnu) compiled by GNU C version 2.7.2.3.
as -V -Qy -o /tmp/cca286141.o /tmp/cca28614.s
GNU assembler version 2.8.1 (i686-pc-linux-gnu), using BFD version linux-2.8.1.0.1
/usr/local/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.90.23/ld -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o smt /usr/lib/crt1.o /usr/lib/crti.o /usr/local/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.90.23/crtbegin.o -L/usr/local/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.90.23 -L/usr/local/lib /tmp/cca286141.o -lgcc -lc -lgcc /usr/local/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.90.23/crtend.o /usr/lib/crtn.o
/tmp/cca286141.o: In function `B<int>::IncCounter(void)':
/tmp/cca286141.o(.B<int>::gnu.linkonce.t.IncCounter(void)+0x8): undefined reference to `B<int>::mycounter'
collect2: ld returned 1 exit status
So perhaps:
* I installed it wrong
I couldn't find any egcs-specific installation instructions
so I used the ones in the toplevel README.
* It just doesn't work yet
* I misunderstood how statics in templates were supposed to work
* I need -frepo or something - there doesn't seem to be much
in the doc on this either. When I use -frepo I get .rpo files,
- do I need to tell the linker to use them?
or
* Something else.
--
Erik Corry