Article View: comp.os.ms-windows.programmer.misc
Article #2790Re: Q: Bor. C++ linker err. when passing template references
From: Pete Becker
Date: Mon, 11 Sep 1995 20:15
Date: Mon, 11 Sep 1995 20:15
30 lines
1659 bytes
1659 bytes
In article <431cjr$k49@earth.alpha.net>, pi@earth.execpc.com says...
>
>What I am doing should be legal (I think), at least the compiler
>doesn't complain about it.
>
>typedef TArray<string> TArrayOfString;
>
>TArrayOfString &Funk(TArrayOfString &MyArray)
> {
> string s;
>
> MyArray.Flush(); // ok, no linker error
>
> MyArray.Add(string); // Fails at link time
>
> return MyArray;
> }
>
>So, this should be legal right? Is this a compiler name
>mangling bug or a linker bug that anyone knows of?
>
Neither. It's a code fragment that never actually uses the template instance,
so the template never gets instantiated. I suspect that what's missing here is
the information that this code lives in a DLL and is being called from another
DLL or an EXE. In that case you have to either create an actual instance of
this template in your DLL to convince the compiler that you need it or use the
-Jg switches to force instantiation. The fact that Flush() is actually there
is misleading. You really don't want to hear the explanation.
-- Pete
Technical Details
Message-ID:
<4325cm$c30@druid.borland.com>Path:
arc1-ca.pugleaf.net!druid.borland.com!usenetReferences:
<431cjr$k49@earth.alpha.net>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!druid.borland.com!usenet From: pete@borland.com (Pete Becker) Newsgroups: comp.os.ms-windows.programmer.misc,comp.lang.c++ Subject: Re: Q: Bor. C++ linker err. when passing template references Date: 11 Sep 1995 20:15:18 GMT Organization: Borland International Message-ID: <4325cm$c30@druid.borland.com> References: <431cjr$k49@earth.alpha.net> NNTP-Posting-Host: sbcandau.borland.com Mime-Version: 1.0 Content-Type: Text/Plain; charset=ISO-8859-1 Keywords: Borland C++, templates, references X-Newsreader: WinVN 0.99.5