bottlenoselabs / c2cs

Generate C# bindings from a C header.
MIT License
250 stars 18 forks source link

Fields in anonymous union inside a struct is not properly handled as documented. #75

Closed AlseinX closed 2 years ago

AlseinX commented 2 years ago

C definition inside the header file:

struct SomeStruct
{
   // other fields
    union
    {
        struct Foo foo;
        struct Bar bar;
    };
    //other fields
};

The struct is correctly taken as LayoutKind.Explicit, and the field offsets of the normal fields are correctly calculated, but the fields inside the anonymous union is simply ignored.

lithiumtoast commented 2 years ago

Thanks @AlseinX 👍

I'll add it to the integration tests once multipass is finished (working on it).

AlseinX commented 2 years ago

Thanks @AlseinX 👍

I'll add it to the integration tests once multipass is finished (working on it).

Would a quick-fix be released to solve this problem?

lithiumtoast commented 2 years ago

I merged the branch in. I'll take a look at this tomorrow.

lithiumtoast commented 2 years ago

Found the issue, working on a solution now.