Using D libs in C

Daniel Green venix1 at gmail.com
Tue Mar 22 15:58:34 PDT 2011


On 3/22/2011 6:46 PM, Dainius (GreatEmerald) wrote:
> I've tried compiling the same on Linux and the program still crashes
> (with segmentation fault there). No error message or anything. And it
> doesn't matter if I compile the thing from .obj or from .lib files, I
> still get the same crashes. So it's a real showtopper for me, since
> what's the use of having static libraries that compile successfully
> yet crash every time you attempt to use them?..
>
> Anyone have any ideas about what's happening? Or should I just go
> ahead and submit this to the bug tracker?

The D runtime needs to be initialized.  Call rt_init before using your 
library and rt_term when your done with it.

The D runtime replaces main with initialization code and renames the 
programs main to _Dmain.

extern (C) bool  rt_init( void delegate( Exception ) dg = null );
extern (C) bool  rt_term( void delegate( Exception ) dg = null );


More information about the Digitalmars-d-learn mailing list