The following style of struct is relatively common in C interfaces, using the unnamed structure or union as a holder for items without requiring an intermediate qualifier:
struct foo {
union {
int x;
double y;
void (*foo) z(void);
};
int more;
} bar;
The names bar.x, bar.y and bar.z are all valid, and they all refer to the same location within the struct.
The name bar.more has an offset from the beginning of the structure calculated as the max of sizes of x, y, and z.
C2HS currently doesn't handle this correctly at all.
Note: I have coded up a smallish patch that handles this correctly. Once I'm satisfied that it tests correctly, I will submit a pull request. But I wanted to get the issue on record, if only to be able to give the test for the bug a name in the test-bugs category.
A pull request (#233) has been submitted for the maintainers' consideration. Works like a charm for me, allowing me to interface to Linux interfaces like the KVM ioctls.
The following style of struct is relatively common in C interfaces, using the unnamed structure or union as a holder for items without requiring an intermediate qualifier:
struct foo { union { int x; double y; void (*foo) z(void); }; int more; } bar;
The names bar.x, bar.y and bar.z are all valid, and they all refer to the same location within the struct. The name bar.more has an offset from the beginning of the structure calculated as the max of sizes of x, y, and z.
C2HS currently doesn't handle this correctly at all. Note: I have coded up a smallish patch that handles this correctly. Once I'm satisfied that it tests correctly, I will submit a pull request. But I wanted to get the issue on record, if only to be able to give the test for the bug a name in the test-bugs category.