Shared library with C API

Dicebot via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Sat May 31 00:03:24 PDT 2014


On Friday, 30 May 2014 at 17:37:04 UTC, Etienne wrote:
> On 2014-05-26 12:33 PM, Kai Nacke wrote:
>>
>> No. Just call rt_init() before you call the first D function. 
>> You should
>> also call rt_term() e.g. on program shutdown. This makes sure 
>> that the D
>> runtime is initialized properly and that resources are freed 
>> on shutdown.
>> You should also make sure that no D exception escapes as C has 
>> no
>> exception handling and D exceptions are not compatible with 
>> C++ exceptions.
>>
>> Regards,
>> Kai
>
> I looked at the p.97 in the D Cookbook, and it calls rt_init() 
> from C.
>
> I was wondering, isn't it easier to put this initialization in 
> a static this(), in the D module directly?

AFAIK module constructors are called by runtime, so with absence 
of rt_init() those will have no effect.


More information about the digitalmars-d-ldc mailing list