17426, "souris-dev", "Support for anonymous C unions/structs in c2chapel", "2021-03-18T07:47:49Z"
Currently, c2chapel
only recognizes C structs in a header file for automatic generation of extern definitions.
PR Support for C unions in c2chapel by souris-dev · Pull Request #17284 · chapel-lang/chapel · GitHub adds support for C unions in a header file and for anonymous C unions/structs (although for now, the changes in the PR just skip the fields in the anonymous union/struct so that c2chapel
doesn't error out).
This issue exists to document the feature request for c2chapel
to support anonymous C unions/structs by "squashing" the fields in the anonymous union/struct, so that something like this:
typedef struct someStruct {
int int_field;
// Anonymous union
union {
char alpha;
int num;
};
} someStruct;
becomes this when processed by c2chapel
:
extern record someStruct {
var int_field: c_int;
var alpha: c_char;
var num: c_int;
}