Hi,
I've been trying to see if I can get an mbed project to work with Dlang
basically compiling D code for use on a Cortex-M Proccessor
So far I've been using the latest release of LDC with the -BetterC Flag From what I can gather, normally without -BetterC it works like this:

  * main() - C main generated by the compiler
  * _d_run_main - called by C main to setup the runtime
  * _Dmain - main function in D land, is called by _d_run_main

With -BetterC enabled, it instead works like this

  * main() - C main generated by the compiler
* _d_run_main - needs to be written by the user since there's no runtime
  * _Dmain - main function in D land

so basically I need to write my own basic _d_run_main to call _Dmain.
Code in github does something like this typically
```
private alias extern(C) int function(char[][] args) MainFunc;
private extern (C) int _d_run_main(int argc, char** argv, MainFunc mainFunc)
{
    return mainFunc(null);
}
```

However the LDC compiler doesn't like this as it expects the mainFunc parameter to be a void pointer
so I tried this instead
```
extern (C) int _d_run_main(int argc, char **argv, void* mainFunc) {
    MainFuncType mFunc = cast(MainFuncType) mainFunc;
    return mFunc(null);
}
```

but nope that didn't seem to work ether, compiles okay but the code in main() (D space) isn't called
I'd imagine this should be a simple thing, anyone got any ideas?

Reply via email to