Problem with GC - linking C++ & D (with gdc)

Claude claudemr at live.fr
Tue Apr 26 10:32:24 UTC 2022


On Tuesday, 26 April 2022 at 10:29:39 UTC, Iain Buclaw wrote:
> On Tuesday, 26 April 2022 at 10:23:15 UTC, Claude wrote:
>> Hello,
>>
>
> Hello,
>
> <%--SNIP--%>
>
>>
>> Does anyone have any idea what's going on?
>>
>> (if I just compile a single D file with "int main() { int* a = 
>> new int(42); return *a; }", it works as intended.)
>
> The `new` keyword requests the druntime GC to allocate memory, 
> however you haven't initialized the D run-time in your program.
>
> main.cpp
> ```D
> extern "C" int rt_init();
> extern "C" const int* ct_parse();
>
> int main(int argc, char ** argv)
> {
>     rt_init();
>     return *ct_parse();
> }
> ```

Ok, thanks!
I should have suspected something like this.


More information about the Digitalmars-d-learn mailing list