I just encountered a problem involving this MacOS header file:
typedef struct {
natural_t pad1;
mach_msg_size_t pad2;
unsigned int pad3 : 24;
mach_msg_descriptor_type_t type : 8;
} mach_msg_type_descriptor_t;
xnu_static_assert_struct_size(mach_msg_type_descriptor_t, 12);
After translation, the code becomes:
// /home/cleong/.zvm/0.16.0/lib/libc/include/any-darwin-any/mach/message.h:296:32: warning: struct demoted to opaque type - has bitfield
pub const mach_msg_type_descriptor_t = opaque {};
comptime {
if (!(@sizeOf(mach_msg_type_descriptor_t) == @as(c_ulong, 12))) @compileError("static assertion failed \"struct changed size unexpectedly\"");
}
So any file that happens to include this header is untranslatable. Demoting structs with bitfields to opaque is not a viable solution. It just breaks too much stuff.