C binding with D function

llaine via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 3 08:24:56 PDT 2016


On Wednesday, 3 August 2016 at 15:14:24 UTC, Kagamin wrote:
> On Wednesday, 3 August 2016 at 15:08:51 UTC, llaine wrote:
>> So basically I have to create wrapper.c ?
>
> Yes, but you should write it in D. Runtime initialization is at 
> https://dlang.org/phobos/core_runtime.html#.Runtime

Okay I tried to do something like this


import std.stdio;
import core.runtime;

extern(C)
{

   void foo(string str)
   {
     writeln(str);
   }

}

void main(){
   Runtime.initialize();
   Runtime.terminate();
}

Am I doing it wrong ?
Still getting a Segmentation fault


More information about the Digitalmars-d-learn mailing list