🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.os.ms-windows.programmer.misc
3 messages
3 total messages Started by Peter Ikusz Mon, 11 Sep 1995 13:12
Q: Bor. C++ linker err. when passing template references
#2787
Author: Peter Ikusz
Date: Mon, 11 Sep 1995 13:12
23 lines
876 bytes
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?

Thanks,
-Pete

Follow-up to: "v$pikusz@qgraph.com"
Re: Q: Bor. C++ linker err. when passing template references
#2790
Author: Pete Becker
Date: Mon, 11 Sep 1995 20:15
30 lines
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
Re: Q: Bor. C++ linker err. when passing template references
#2788
Author: Laura Allender
Date: Mon, 11 Sep 1995 20:47
30 lines
1438 bytes
Two possibilities:
1) You haven't included the appropriate classlib files in your code (unlikely)
2) You haven't created an object of TArrayOfString.
      In this case, the template has not been fleshed out so the linker gets
      confused.  If you are trying to test other code and you want to keep this
      problematic stuff around before you finish it add a line like this 
      to your code  (a local variable will do):

            TArrayOfString dontwantitbutneedit;
   
Laura  

In article <431cjr$k49@earth.alpha.net>, pi@earth.execpc.com (Peter Ikusz)
wrote:

> 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;
>         }
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads