Dynamic D Library

BCS ao at pathlink.com
Mon Jul 27 10:17:35 PDT 2009


Reply to teo,

> I did some tests and here are the results: D cannot be used in Shared
> Objects. The only case that works is when no classes are exported and
> when there are no references to Phobos within the library.
> 

two of your fail cases have non SO realted errors:

> ==========
> DOESN'T WORK without extern(C). Cannot compile the program.
> module test; // file "test.d"
> int test()
> {
> return 1;
> }
> ---
> module main; // file "prog.d"
> import std.stdio;
> extern(C) int test();

this should not be extern(C).

> void main()
> {
> writefln("Result: %d", test());
> return;
> }
> ==========
> DOESN'T WORK with classes defined in the library. The program cannot
> be compiled.
> module test; // file "test.d"
> extern(C)
> {
> class Test
> {
[...]
> }
> }

An extern(C) class would be meaningless and I don't think they are even legal. 
I can't seem tor repro it with the version I have here (1.034) but I got 
an error from this code on another system:

extern(C) class C { }
C Fn(){return new C();}





More information about the Digitalmars-d mailing list