digitalmars.D.learn - Link error with template struct on 2.042
- Frank Fischer (36/36) Mar 31 2010 Hi,
- Regan Heath (8/32) Mar 31 2010 It is either implementing a function, or not calling one - sometimes
- Frank Fischer (5/15) Mar 31 2010 Yes, exactly those two files. Nothing more, nothing less. The example
- Regan Heath (3/12) Mar 31 2010 Ahh.. I am on Windoze.. interesting.
- Jacob Carlborg (3/39) Mar 31 2010 I don't know if I'm missing something but don't you have to compile
- Frank Fischer (7/9) Mar 31 2010 Of course, you're right. Don't know why I expected dmd to compile the
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
Mar 31 2010
Frank Fischer wrote:If I compile the above example with dmd main.dWeird, that command line works fine for me, no errors.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.It is either implementing a function, or not calling one - sometimes debug mode will enable extra functions, I note the above undefined reference is to a symbol called MyMod.assert being called from MyStruct.opAssign. Was that a complete code sample? Regan
Mar 31 2010
On 2010-03-31, Regan Heath <regan netmail.co.nz> wrote:Frank Fischer wrote:Strange. I used the linux version 2.042, just downloaded.If I compile the above example with dmd main.dWeird, that command line works fine for me, no errors.It is either implementing a function, or not calling one - sometimes debug mode will enable extra functions, I note the above undefined reference is to a symbol called MyMod.assert being called from MyStruct.opAssign. Was that a complete code sample?Yes, exactly those two files. Nothing more, nothing less. The example also works if I put the struct in the file main.d. Frank
Mar 31 2010
Frank Fischer wrote:On 2010-03-31, Regan Heath <regan netmail.co.nz> wrote:Ahh.. I am on Windoze.. interesting. RFrank Fischer wrote:Strange. I used the linux version 2.042, just downloaded.If I compile the above example with dmd main.dWeird, that command line works fine for me, no errors.
Mar 31 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 FrankI don't know if I'm missing something but don't you have to compile MyMod.d also ?
Mar 31 2010
On 2010-03-31, Jacob Carlborg <doob me.com> wrote:I don't know if I'm missing something but don't you have to compile MyMod.d also ?Of course, you're right. Don't know why I expected dmd to compile the other files as well, propably because it worked without the this(this) function. I'm really happy it was only my stupidity ;) Thanks, Frank
Mar 31 2010