ClangSharp
ClangSharp copied to clipboard
Unions inside functions aren't handled correctly
C code:
extFloat80_t extF80_add( extFloat80_t a, extFloat80_t b )
{
union { struct extFloat80M s; extFloat80_t f; } uA;
...
The generated C# code:
[return: NativeTypeName("extFloat80_t")]
public static extFloat80M extF80_add([NativeTypeName("extFloat80_t")] extFloat80M a, [NativeTypeName("extFloat80_t")] extFloat80M b)
{
[StructLayout(LayoutKind.Explicit)]
public partial struct __AnonymousRecord_extF80_add_L47_C5
{
[FieldOffset(0)]
[NativeTypeName("struct extFloat80M")]
public extFloat80M s;
[FieldOffset(0)]
[NativeTypeName("extFloat80_t")]
public extFloat80M f;
}
, uA = new __AnonymousRecord_extF80_add_L47_C5()
...
This is one that isn't really "easy" to handle.
There is no corresponding concept for defining a struct inside a function in C#/.NET and so it must be "hoisted" out instead. This risks conflicts and other issues, so its not something that's trivial to handle.