Compililng C++ and D together without going mad

Jan Hönig hrominium at gmail.com
Wed Apr 29 13:14:40 UTC 2020


On Wednesday, 29 April 2020 at 13:12:50 UTC, Johan wrote:
> Manually initializing D's runtime is also possible. You need to 
> call rt_init and rt_term: 
> https://dlang.org/phobos/core_runtime.html#.rt_init
>
> What I meant is to
> - add a `int main(....)` in a D source file
> - rename your current `main` in the C++ source file to 
> something like `the_real_main`
> - add a forward reference to the D file: `extern(C) int 
> the_real_main(....);`
> - call `the_real_main` from the `main` in the D file
>
> That way you don't have to think about how to correctly 
> initialize D's runtime.
>
> -Johan

I thought it was a good idea to ask in the forum!
This actually helps me a lot, thanks!


More information about the Digitalmars-d-learn mailing list