Dynamic D Library
teo
teo.ubuntu.remove at yahoo.com
Mon Jul 27 13:07:50 PDT 2009
On Mon, 27 Jul 2009 17:17:35 +0000, BCS wrote:
> 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:
>
Correct. These are shortcomings of D.
>> ==========
>> 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).
>
How will you do it? Give me an example please.
>> 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();}
I use v2.031 and cannot export a class out of a library.
More information about the Digitalmars-d
mailing list