More testing. This:

--- file mylib.d
module mylib;
import core.runtime;
import std.stdio;

extern(C) {
        bool mylib_init() {
                return Runtime.initialize();
        }
        
        bool mylib_free() {
                return Runtime.terminate();
        }

        void mylib_hello() {
                writeln("Hello from mylib");
        }
}

void main() {} // Fake main
---

--- file main.c ---
extern int mylib_init();
extern int mylib_free();
extern void mylib_hello();

int main() {
        mylib_init();
        mylib_hello();
        mylib_free();
        return 0;
}
---

$ dmd -c mylib.d
$ gcc -o main main.c mylib.o -lphobos2 -lpthread -lrt
$ ./main

works on Linux (Unbuntu 11.10), but segfaults on OS X Lion.


Reply via email to