www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [0.89 linux]Template alias

reply Stephan Wienczny <Stephan Wienczny.de> writes:
The attached files compile but do not link. There is an undefined reference
to the template constructor.
If I copy it into one file it works...
May 20 2004
next sibling parent reply "Carlos Santander B." <carlos8294 msn.com> writes:
"Stephan Wienczny" <Stephan Wienczny.de> escribió en el mensaje
news:c8jhfj$nfd$1 digitaldaemon.com
| The attached files compile but do not link. There is an undefined
reference
| to the template constructor.
| If I copy it into one file it works...

Works for me:
dmd modules.d token.d

Probably you're forgetting to put "token.d". Don't, so it'll get linked.
Another option:
dmd -c modules token
link modules.obj token.obj

-----------------------
Carlos Santander Bernal
May 20 2004
parent Stephan Wienczny <wienczny web.de> writes:
Do you use Windows? Then this might be a linux only bug. I'm pretty sure 
that the file is linked in.

Stephan

Carlos Santander B. wrote:
 
 Works for me:
 dmd modules.d token.d
 
 Probably you're forgetting to put "token.d". Don't, so it'll get linked.
 Another option:
 dmd -c modules token
 link modules.obj token.obj
 
 -----------------------
 Carlos Santander Bernal
 
 
May 21 2004
prev sibling next sibling parent Stephan Wienczny <Stephan Wienczny.de> writes:
Stephan Wienczny wrote:

 The attached files compile but do not link. There is an undefined
 reference to the template constructor.
 If I copy it into one file it works...
I looked at the files using nm. nm showed that the undefined references are local symbols instead of global ones. Stephan
May 21 2004
prev sibling parent Stephan Wienczny <wienczny web.de> writes:
Template instances are still not handled correctly on Linux.
The compiler generates lokal symbols for template instances. This is the 
reason why you can't link it.


Stephan Wienczny wrote:
 The attached files compile but do not link. There is an undefined reference
 to the template constructor.
 If I copy it into one file it works...
 
 
 
 
 ------------------------------------------------------------------------
 
 
 import std.file, std.stream, token;
 
 int main(char[][] argv)
 {
     new IntToken(32, null);    
     return 0;
 }
 
 
 ------------------------------------------------------------------------
 
 
 class Location
 {
 
 }
 
 class Token
 {
 	this(Location _loc)
 	{
 		loc = _loc;
 	}
 	
 	Location loc;
 }
 
 
 class NumberToken(T) : public Token
 {
 	T value;
 //	char[] suffix;
 	
 	this(T _value/*, char[] _suffix*/, Location _loc)
 	{
 	    super(_loc);
 	    value = _value;
 //	    suffix = _suffix;
 	}
 }
 
 alias NumberToken!(int)		IntToken;
 alias NumberToken!(uint)	UIntToken;
 alias NumberToken!(long)	LongToken;
 alias NumberToken!(ulong)	ULongToken;
 alias NumberToken!(real)	RealToken;
 alias NumberToken!(ireal)	IRealToken;
 
May 29 2004