On Wednesday, 3 August 2016 at 13:44:46 UTC, llaine wrote:
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!

Probably because you need the D runtime. One way is to import core.runtime and call Runtime.initialize().

Reply via email to