C.h to D conversion (structs)
Chris via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Mar 15 09:32:56 PDT 2016
I've converted a C.h file to D according to this guide:
http://wiki.dlang.org/Converting_C_.h_Files_to_D_Modules
and examples in deimos:
https://github.com/D-Programming-Deimos/
However, I get an error when trying to use a struct that uses
structs.
struct A
{
size_t i;
}
struct B
{
size_t x;
}
struct C
{
A a;
B b;
}
The error I get is something like
undefined reference to `_D3test7testmodule13A6__initZ'
undefined reference to `_D3test7testmodule13B6__initZ'
// The C header would look like this:
typedef struct _A
{
size_t i;
} A;
typedef struct _B
{
size_t x;
} B;
typedef struct _C
{
A a;
B b;
} C;
Also, what do I do with C structs that contain the following:
typedef struct _A
{
struct _A *next;
struct _A *prev;
} A;
Thanks.
More information about the Digitalmars-d-learn
mailing list