Problem with GC - linking C++ & D (with gdc)
    Iain Buclaw 
    ibuclaw at gdcproject.org
       
    Tue Apr 26 10:29:39 UTC 2022
    
    
  
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();
}
```
    
    
More information about the Digitalmars-d-learn
mailing list