Link error with template struct on 2.042

Jacob Carlborg doob at me.com
Wed Mar 31 01:49:48 PDT 2010


On 3/31/10 09:26, Frank Fischer wrote:
> Hi,
>
> after some time I started again playing with D. The following example
> gives an error I don't understand (I'm trying dmd 2.042):
>
> ==== main.d ====
> import MyMod;
>
> void main()
> {
>      MyStruct!(int) s;
> }
>
> ==== MyMod.d ===
> module MyMod;
>
> struct MyStruct(T) {
>      this(this) {}
> }
> ================
>
> If I compile the above example with
>
> dmd main.d
>
> I get the following error:
>
> main.o: In function
> `_D5MyMod15__T8MyStructTiZ8MyStruct10__postblitMFZv':
> main.d:(.text._D5MyMod15__T8MyStructTiZ8MyStruct10__postblitMFZv+0x12):
> undefined reference to `_D5MyMod8__assertFiZv'
> main.o: In function
> `_D5MyMod15__T8MyStructTiZ8MyStruct8opAssignMFNcS5MyMod15__T8MyStructTiZ8MyStructZS5MyMod15__T8MyStructTiZ8MyStruct':
> main.d:(.text._D5MyMod15__T8MyStructTiZ8MyStruct8opAssignMFNcS5MyMod15__T8MyStructTiZ8MyStructZS5MyMod15__T8MyStructTiZ8MyStruct+0x12):
> undefined reference to `_D5MyMod8__assertFiZv'
> collect2: ld returned 1 exit status
> --- errorlevel 1
>
> What does this mean? Note that everything works fine if MyStruct is
> not a template, if there's no function this(this) or if I compile the
> example with assertions disabled like this:
>
> dmd -release main.d
>
> It seems as I'm missing to implement some function, but I don't know
> which.
>
> Thanks in advance
> Frank
>

I don't know if I'm missing something but don't you have to compile 
MyMod.d also ?


More information about the Digitalmars-d-learn mailing list