calling D2 routines from C routines on linux

Andrej Mitrovic andrej.mitrovich at gmail.com
Tue Jul 19 16:48:15 PDT 2011


See if this works for you:

import core.runtime;

void myMainFunc()
{
}

extern (C)
int initializeDee()
{
    int result;
    void exceptionHandler(Throwable e) { throw e; }

    try
    {
        Runtime.initialize(&exceptionHandler);
        result = myMainFunc();
        Runtime.terminate(&exceptionHandler);
    }
    catch (Throwable o)
    {
        result = 0;
    }
    return result;
}

This is similar to how it's done for Windows GUI applications, where
we have to manually run the initialize function in druntime (unless
it's hidden by some GUI framework).


More information about the Digitalmars-d-learn mailing list