haskell / haskell/c2hs

unnamed struct elements and union elements not supported

Open
#230 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
211
Forks
52
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.