Object.factory fails for static libraries

Andre Pany via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jun 4 09:12:04 PDT 2016


Hi,

I try to create objects by using the factory method in a static 
library scenario.


file base.d
-------------------------------
module base;
class Base { }

Object createObject(string name)
{
   return Object.factory(name);
}
-------------------------------


file child.d
-------------------------------
module child;
import base;
class Child: Base { }
-------------------------------

file main.d
-------------------------------
import base, child;

void main()
{
     import std.traits: fullyQualifiedName;
     assert( Object.factory(fullyQualifiedName!Child) !is null);
     assert( createObject(fullyQualifiedName!Base) !is null);
     assert( createObject(fullyQualifiedName!Child) !is null);
}
-------------------------------

My windows batch file looks like this:
dmd base -lib
dmd child -lib base.lib
dmd main base.lib child.lib
main
PAUSE

All assertions fails. Should this work, or is this a restriction
of object.factory?

Kind regards
André


More information about the Digitalmars-d-learn mailing list