public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* Re: Template Class Problem
@ 1999-04-30 23:15 Mike Stump
  0 siblings, 0 replies; 3+ messages in thread
From: Mike Stump @ 1999-04-30 23:15 UTC (permalink / raw)
  To: egcs-bugs, gutier

> From: Gerald Gutierrez <gutier@intergate.bc.ca>
> To: egcs-bugs@egcs.cygnus.com
> Date: Tue, 27 Apr 1999 00:33:50 -0700

> Below is what I believe to be another problem with templates.

Yes and no.  Yes, long term the compiler will switch over to work how
you expect.  We know about this.  But, it is unlikely to happen
anytime soon.  In the mean time, you must include all definitions in
all files that make any use of templates.  This is a limitation of
many C++ compilers.

> I've got a parameterized class called Alpha within the files
> Alpha.cc and Alpha.h.  They compile fine but after the compile
> Alpha.o doesn't contain any symbols relating to the Alpha class!

It is working as designed.  Use -frepo, or try defining the termplates
in all files that use them.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Template class problem
@ 2002-07-10 11:46 C Chan
  0 siblings, 0 replies; 3+ messages in thread
From: C Chan @ 2002-07-10 11:46 UTC (permalink / raw)
  To: bug-gcc

How can I tell the compiler to instantiations the template class( not the
stl lib, I build a library to have template calss)?
I have been including the source file ( e.g. #include "template1.cpp" in the
template1.h file).
Then I setted the INCLUDE_TEMPLATE_DEFINITION macro in the Makefile. But it
still does not work.

Thanks.

CC Chan


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Template Class Problem
@ 1999-04-27 21:31 Gerald Gutierrez
  0 siblings, 0 replies; 3+ messages in thread
From: Gerald Gutierrez @ 1999-04-27 21:31 UTC (permalink / raw)
  To: egcs-bugs

EGCS-1.1.2
Redhat 5.2 Intel

Below is what I believe to be another problem with templates. I've got a
parameterized class called Alpha within the files Alpha.cc and Alpha.h.
They compile fine but after the compile Alpha.o doesn't contain any
symbols relating to the Alpha class! Naturally, links against this file
fail.

If this is somehow my fault or it is a bug and there is a workaround,
please let me know. This particular problem is seriously hosing me ...

[ template_bug]$ ls -l
total 2
-rw-rw-r--   1 gerald   gerald        114 Apr 27 00:33 Alpha.cc
-rw-rw-r--   1 gerald   gerald         82 Apr 27 00:32 Alpha.h
[ template_bug]$ cat Alpha.h

template<class T>
class Alpha

public:
    Alpha (void);
    ~Alpha (void);
};

[ template_bug]$ cat Alpha.cc

#include "Alpha.h"

template<class T>
Alpha<T>::Alpha (void) { }

template<class T>
Alpha<T>::~Alpha (void) { }

[ template_bug]$ g++ -c Alpha.cc
[ template_bug]$ ls -l
total 3
-rw-rw-r--   1 gerald   gerald        114 Apr 27 00:33 Alpha.cc
-rw-rw-r--   1 gerald   gerald         82 Apr 27 00:32 Alpha.h
-rw-rw-r--   1 gerald   gerald        817 Apr 27 00:38 Alpha.o
[ template_bug]$ nm --demangle Alpha.o
00000000 ? __FRAME_BEGIN__
00000000 t gcc2_compiled.
[ template_bug]$ 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-07-10 18:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-04-30 23:15 Template Class Problem Mike Stump
  -- strict thread matches above, loose matches on Subject: below --
2002-07-10 11:46 Template class problem C Chan
1999-04-27 21:31 Template Class Problem Gerald Gutierrez

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).