C binding with D function

llaine via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 3 06:44:46 PDT 2016


Hi guys,

I'm trying to make a bridge between D and ruby with a gem called 
ffi.
It's basically a loading/binding library that grab C function and 
make them callable from Ruby code.

As you might already understand, i'm trying to develop extensions 
using D and uses them in Ruby.

I tried to get the simplest example ever but nothing is working 
so far.

Basically here is my D code :

import std.stdio : writeln;

extern(C)
{
   void puts(string str)
   {
     writeln(str);
   }
}

void main(){ }

I'm building it using "targetType": "dynamicLibrary" on my 
dub.json


My problem is when I try to call it in C, it blows up with a 
segmentation fault.
I'm looking for here extra documentation/help on how to properly 
create C binding in D.

I already post an issue on FFI to seek from help, you can find 
here some extra informations about the C trace


https://github.com/ffi/ffi/issues/522


Any help would be welcomed!


More information about the Digitalmars-d-learn mailing list