Reply to teo,

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.


Remove "extern(C)" from the prototype in that example an try it again?

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.

Have you tried that example case again but with all "exter(C)" removed?


Reply via email to