home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!elroy.jpl.nasa.gov!usc!zaphod.mps.ohio-state.edu!cs.utexas.edu!ut-emx!jamshid
- From: jamshid@ut-emx.uucp (Jamshid Afshar)
- Newsgroups: comp.std.c++
- Subject: Re: need help compiling (linking) Borland C++ programs using templates
- Summary: #include the .cpp file in the template's header file
- Message-ID: <85727@ut-emx.uucp>
- Date: 22 Dec 92 21:52:07 GMT
- References: <1992Dec17.231411.10943@engage.pko.dec.com>
- Reply-To: jamshid@emx.utexas.edu
- Organization: The University of Texas at Austin; Austin, Texas
- Lines: 42
-
- In article <1992Dec17.231411.10943@engage.pko.dec.com> chou@riscee.pko.dec.com (Jesse Chou WSG/SECG) writes:
- >This may be a very basic and silly question to ask but I am new to Borland
- >c++. It is greatly appreciated that someone could enlighten me or give me
- >pointer to a FAQ.
-
- The comp.lang.c++ FAQL is available by anonymous ftp at
- sun.soe.clarkson.edu in the file pub/C++/FAQ (though there's not much
- on templates).
-
- >I am writing a list class using template and got link error:
- >Error: Undefined symbol slist_base::append(slink near*) in module tpc.cpp
- >I had a similar error using other c++ compiler and found that I have to use
- >a command line switch with the compiler.
-
- Different compilers currently do not handle the generation of template
- functions in the same way. The ARM leaves a lot unspecified and I'm
- not sure what ANSI C++ will say about it. Make sure you read your
- compiler manuals as there are often different ways to do it even with
- the same compiler, each method offering different tradeoffs.
-
- The easiest way to do deal with this under BC++ (and I believe gcc) is
- to just #include the .cpp file containing the non-inline template
- functions in the corresponding header file.
-
- // List.h
- #ifndef List_H
- #define List_H
-
- template<class T> class List { /*...*/ };
- //...
-
- #ifndef DONT_NEED_CPP
- #include "List.cpp"
- #endif
-
- #endif // List_H
-
- Jamshid Afshar
- jamshid@emx.utexas.edu
-
-
-
-