C.h to D conversion (structs)

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Mar 15 09:44:10 PDT 2016


On Tuesday, 15 March 2016 at 16:32:56 UTC, Chris wrote:
> The error I get is something like
>
> undefined reference to `_D3test7testmodule13A6__initZ'
> undefined reference to `_D3test7testmodule13B6__initZ'


You still need to compile/link in the module (or in this specific 
case, void initialize the structs) so any little functions or 
initializers are present.

In C, structs need to be initialized manually, but in D they are 
automatically set to some initial value for each field. That 
initial value is the referenced __init symbol and still comes out 
of the .o file, like a function would.


More information about the Digitalmars-d-learn mailing list