* Win32 issues with Templates and Libs *
kris
foo at bar.com
Mon Feb 19 16:07:47 PST 2007
dmd on Win32 has recently become much better at handling Templates and
libs, but it still has some issues. I got lucky and isolated one of
them, listed below:
Two modules, one called test.d and the other tester.d -- add test.d to a
library called test.lib, and then compile+link tester.d against said
lib. You should get a correctly linked app that runs and emits "hello".
============
module test;
extern (C) int printf (char*, ...);
class Test (T)
{
final void show (T[] msg)
{
printf ("%.*s\n", msg);
}
}
//Test!(char) Global;
==========
==========
module tester;
pragma (lib, "test.lib");
import test;
void main()
{
auto t = new Test!(char);
t.show ("hello");
}
==========
Now, remove the comment in test.d so that 'Global' is exposed, and
rebuild the lib. You should now get linker errors of this nature:
>dmd tester
C:\d\dmd\bin\..\..\dm\bin\link.exe tester,,,user32+kernel32/noi;
OPTLINK (R) for Win32 Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved
tester.obj(tester)
Error 42: Symbol Undefined _D4test11__T4TestTaZ4Test7__ClassZ
tester.obj(tester)
Error 42: Symbol Undefined _D4test11__T4TestTaZ4Test4showMFAaZv
--- errorlevel 2
This error does not occur with dmd on linux, nor when using GDC on any
supported platform that we've tried. It's only the dmd/Win32 combination
Please can we have this fixed soon?
More information about the Digitalmars-d
mailing list