prolog and epilog code

Rufus Smith via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Aug 2 10:04:08 PDT 2016


On Tuesday, 2 August 2016 at 16:30:08 UTC, Adam D. Ruppe wrote:
> On Tuesday, 2 August 2016 at 16:21:07 UTC, Rufus Smith wrote:
>> How does one use C main? extern C?
>
> extern(C) int main()
>
> should do it

It doesn't seem to be that easy!

https://wiki.dlang.org/Runtime_internals

If I do this then I get lots of missing imports(the D runtime).


import std.stdio;
import core.runtime;

private alias extern(C) int function(char[][] args) MainFunc;
extern int _d_run_main(int argc, char **argv, MainFunc mainFunc);

extern(C) void main(int argc, char **argv)
{
   rt_init();
   _d_run_main(argc, argv, &_main);
   rt_term();
}

extern(C) int _main(char[][] args) { return 0; }


Or even using the code from the wiki, I get unresolved externals. 
Mainly the druntime like stuff(typeinfo, aa stuff, etc...).





More information about the Digitalmars-d-learn mailing list