Thread overview
[0.89 linux]Template alias
May 21, 2004
Stephan Wienczny
May 21, 2004
Stephan Wienczny
May 21, 2004
Stephan Wienczny
[0.9.1 linux] was [0.89 linux]Template alias
May 29, 2004
Stephan Wienczny
May 21, 2004
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 21, 2004
"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 21, 2004
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
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 29, 2004
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;
>