Creating Libraries Callable from C
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Apr 26 19:15:58 PDT 2014
On 04/26/2014 11:27 AM, Rémy Mouëza wrote:
> You will also have to declare 2 function for initializing and
> terminating D's runtime:
> char rt_init(long long);
> char rt_term(long long);
>
> call rt_init(0) before using your D functions (this will initialize D
> runtime - the D GC amongst other things), then use rt_term(0) at the end
> of the program - you may want to register an exit function with atexit().
And if those functions are called from the library's own initialization
and deinitialization functions, the C program need not know anything
about the D runtime dependence:
void mylib_init() {
rt_init(0);
// ... other initialization
}
Ali
More information about the Digitalmars-d-learn
mailing list