Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
July 05, 2005 std.boxer fail to link | ||||
---|---|---|---|---|
| ||||
module core; import std.boxer; class A { int x, y; } int main(char[][] args) { Box b = box(null); // (*) A a = unbox!(A)(b); assert(a is null); return 0; } D:\proj\dtest>dmd core.d C:\dmd\bin\..\..\dm\bin\link.exe core,,,user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved core.obj(core) Error 42: Symbol Undefined _assert_3std5boxer core.obj(core) Error 42: Symbol Undefined __init_17TypeInfo_C4core1A --- errorlevel 2 Once I'll use non-null value in line (*) second error would disappear. I'm not sure this is a bug... maybe there is my mistake here. Correct me if I do smthing wrong. -- Victor (aka nail) Nakoryakov nail-mail<at>mail<dot>ru Krasnoznamensk, Moscow, Russia |
July 05, 2005 Re: std.boxer fail to link | ||||
---|---|---|---|---|
| ||||
Posted in reply to Victor Nakoryakov | In article <daeceh$dk7$1@digitaldaemon.com>, Victor Nakoryakov says... > >module core; >import std.boxer; > >class A >{ > int x, y; >} > >int main(char[][] args) >{ > Box b = box(null); // (*) > A a = unbox!(A)(b); > assert(a is null); > > return 0; >} > >D:\proj\dtest>dmd core.d >C:\dmd\bin\..\..\dm\bin\link.exe core,,,user32+kernel32/noi; >OPTLINK (R) for Win32 Release 7.50B1 >Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved > >core.obj(core) > Error 42: Symbol Undefined _assert_3std5boxer >core.obj(core) > Error 42: Symbol Undefined __init_17TypeInfo_C4core1A >--- errorlevel 2 > >Once I'll use non-null value in line (*) second error would disappear. > >I'm not sure this is a bug... maybe there is my mistake here. Correct me if I do smthing wrong. > >-- >Victor (aka nail) Nakoryakov >nail-mail<at>mail<dot>ru > >Krasnoznamensk, Moscow, Russia Krasnoznamensk, Below I've reworked your example, hopefully your'll find it useful. # // Core.d # // Must compile with the "-release" switch # // To Compile: dmd core.d -release # module core; # private import std.boxer; # private import std.stdio; # # class A # { # int x, y; # } # # int main(char[][] args) # { # // should allocate memory for this object # A a = new A; # # // have to cast() null to the object type # Box b = box(cast(A)null); // (*) # # // because object is now set to null, # // its memory will be deallocate memory... # // thus the isNull() returns true. # a = unbox!(A)(b); # writefln("Object is null=%s (Memory deallocated)", # (isNull(a) == 1 ? "true" : "false")); # # // need to reallocate memory for this # // object, if you want to use it again # a = new A; # a.x = 12; # a.y = 500; # b = box(a); # a = unbox!(A)(b); # writefln("Object is null=%s (Memory reallocated)", # (isNull(a) == 1 ? "true" : "false")); # # writefln("Class A value: a.x=%d, a.y=%d", a.x, a.y); # # return 0; # } # # bool isNull(in Object o) # { # if (o is null) # return true; # else # return false; # } Output: --------------- C:\dmd>dmd core.d -release C:\dmd\bin\..\..\dm\bin\link.exe core,,,user32+kernel32/noi; C:\dmd>core Object is null=true (Memory deallocated) Object is null=false (Memory reallocated) Class A value: a.x=12, a.y=500 C:\dmd> David L. ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!" ------------------------------------------------------------------- MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.html |
July 06, 2005 Re: std.boxer fail to link | ||||
---|---|---|---|---|
| ||||
Posted in reply to David L. Davis | David L. Davis wrote: > # // Must compile with the "-release" switch > # // To Compile: dmd core.d -release Must? Well, but what if I want to preserve assert/in/out checkings in my module. This disturbs me most of all. Actually I can't understand why linker couldn't find 'assert' symbol. I thought phobos was compiled using -release flag and so all asserts/in/out are striped. Am I wrong? -- Victor (aka nail) Nakoryakov nail-mail<at>mail<dot>ru Krasnoznamensk, Moscow, Russia |
July 06, 2005 Re: std.boxer fail to link | ||||
---|---|---|---|---|
| ||||
Posted in reply to Victor Nakoryakov | In article <dag4rk$1qob$1@digitaldaemon.com>, Victor Nakoryakov says... > >David L. Davis wrote: >> # // Must compile with the "-release" switch >> # // To Compile: dmd core.d -release > >Must? Well, but what if I want to preserve assert/in/out checkings in my module. This disturbs me most of all. > >Actually I can't understand why linker couldn't find 'assert' symbol. I thought phobos was compiled using -release flag and so all asserts/in/out are striped. Am I wrong? > >-- >Victor (aka nail) Nakoryakov >nail-mail<at>mail<dot>ru > >Krasnoznamensk, Moscow, Russia Victor, I had a similar problem with std.boxer as you're having now in May 2005, and here's a link to what Burton Radons the creator of the std.boxer module said about the need for using the "-release" commandline switch to link in D code. http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/4120 David L. ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!" ------------------------------------------------------------------- MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.html |
July 06, 2005 Re: std.boxer fail to link | ||||
---|---|---|---|---|
| ||||
Posted in reply to David L. Davis | David L. Davis wrote: > In article <dag4rk$1qob$1@digitaldaemon.com>, Victor Nakoryakov says... > >>David L. Davis wrote: >> >>># // Must compile with the "-release" switch >>># // To Compile: dmd core.d -release >> >>Must? Well, but what if I want to preserve assert/in/out checkings in my module. This disturbs me most of all. >> >>Actually I can't understand why linker couldn't find 'assert' symbol. I thought phobos was compiled using -release flag and so all asserts/in/out are striped. Am I wrong? >> >>-- >>Victor (aka nail) Nakoryakov >>nail-mail<at>mail<dot>ru >> >>Krasnoznamensk, Moscow, Russia > > > Victor, > > I had a similar problem with std.boxer as you're having now in May 2005, and > here's a link to what Burton Radons the creator of the std.boxer module said > about the need for using the "-release" commandline switch to link in D code. > > http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/4120 > > David L. > > ------------------------------------------------------------------- > "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!" > ------------------------------------------------------------------- > > MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.html Thanks for the link, I've catch problem. But there is another problem. I copied boxer.d into the project, then I try to compile following: class XA {} class XB : XA {} XA xa1 = new XA(); XB xb1 = new XB(); Box b1 = box(xa1); //Box b2 = box(xb1); unbox!(XB)(b1); And linking failed with message: Error 42: Symbol Undefined __init_48TypeInfo_C_D4rame5scene5basic11__unittest0FZv2XB Once I uncomment commented line or move whole boxer module body into source file where I implemented snipet all compiles, links and works fine. I think this is a bug with arrays of TypeInfo used in boxer.d, I figured out problems with these arrays several months ago and post report but it was ignored. I'll try localize the bug and will make one more post. -- Victor (aka nail) Nakoryakov nail-mail<at>mail<dot>ru Krasnoznamensk, Moscow, Russia |
Copyright © 1999-2021 by the D Language Foundation