Shared library with C API

Dan Olson via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Wed Jun 4 08:18:22 PDT 2014


"Ellery Newcomer" <ellery-newcomer at utulsa.edu> writes:

> On Friday, 30 May 2014 at 17:37:04 UTC, Etienne wrote:
>>
>> I was wondering, isn't it easier to put this initialization in a
>> static this(), in the D module directly?
>
> no. use pragma(LDC_global_crt_ctor).
>
> fyi pyd builds shared libraries in the same way you want to
>
> https://bitbucket.org/ariovistus/pyd/src/7fe2f9cf98da2fbd2b26bb30a5d93245c25ec742/infrastructure/d/python_so_linux_boilerplate.d?at=default

LDC also uses global ctors to build the ModuleInfo list.  A problem with
calling rt_init() in a global ctor means that ModuleInfo is probably
incomplete, meaning some or no module ctors (static this) are called.  I
thought perhaps the LDC_global_crt_ctor optional priority arg could
help, but makes no difference on OSX at least.
-- 
Dan


More information about the digitalmars-d-ldc mailing list