Package module not working properly
Jacob Carlborg
doob at me.com
Wed Aug 14 07:43:46 PDT 2013
I'm trying to the get the "package modules" working in the new package
std.serialization I'm working on. I have a sample file I'm compiling,
looking like this:
import std.serialization;
import std.serialization.archives;
class Foo
{
int a;
}
void main ()
{
auto archive = new XmlArchive!();
auto serializer = new Serializer(archive);
auto foo = new Foo;
foo.a = 3;
serializer.serialize(foo);
auto foo2 = serializer.deserialize!(Foo)(archive.untypedData);
assert(foo2.a == 3);
assert(foo.a == foo2.a);
}
When I compile it I get these linker errors:
Undefined symbols for architecture x86_64:
"_D3std13serialization12__ModuleInfoZ", referenced from:
_D4main12__ModuleInfoZ in main.o
"_D3std13serialization8archives12__ModuleInfoZ", referenced from:
_D4main12__ModuleInfoZ in main.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
--- errorlevel 1
If I instead only import the exact modules that are needed, like this:
import std.serialization.serializer;
import std.serialization.archives.xmlarchive;
Everything works as expected.
I have a module declaration in std/serialization/package.d, like this:
module std.serialization;
And in std/serialization/archives/package.d
module std.archives;
First, I don't know if I should have any module declarations at all in
these "package modules". Or if they should be like above or something
like "module std.archives.package;".
If I remove the module declarations in the package modules I get this
assertion in the compiler:
Assertion failed: (p->isPkgMod == PKGmodule), function load, file
import.c, line 136.
Abort trap:
I don't know if I'm doing something wrong of if this new feature isn't
working properly.
The code is available there:
https://github.com/jacob-carlborg/phobos/tree/serialization
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list