C binding with D function
    llaine via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Thu Aug  4 03:36:05 PDT 2016
    
    
  
On Wednesday, 3 August 2016 at 16:09:15 UTC, bachmeier wrote:
> On Wednesday, 3 August 2016 at 15:56:34 UTC, llaine wrote:
>> Okay on stack overflow, they are not using ffi but dl.
>> I tried changing ffi to dl, it's the same don't work 
>> unfortunatly.
>
> That's about as far as I can go without having it set up on my 
> machine. The procedure should be the same as I spelled out 
> though. You need to create an extern(C) function that calls 
> Runtime.initialize(). Then you call that function from Ruby the 
> same as any other function you call with FFI. I'm familiar with 
> the R FFI and the only difference is that some parts of that 
> are automated.
Thank's for the help.
By creating two methods initialize/terminate using 
Runtime.initialize() it's crashing with this strange error.
I looked at the core.runtime source file and I saw a C binding 
for thoses one :
https://github.com/dlang/druntime/blob/master/src/core/runtime.d#L36
/// C interface for Runtime.initialize, returns 1/0 instead of 
bool
extern(C) int rt_init();
/// C interface for Runtime.terminate, returns 1/0 instead of bool
extern(C) int rt_term();
Any idea how can I call them ?
    
    
More information about the Digitalmars-d-learn
mailing list