C.h to D conversion (structs)

Chris via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Mar 15 09:56:00 PDT 2016


On Tuesday, 15 March 2016 at 16:44:10 UTC, Adam D. Ruppe wrote:
> 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.

Do you mean I need to void initialize them in the C code or in D? 
And if in D, how would I do that, with `static this`?


More information about the Digitalmars-d-learn mailing list