The question is if I see a bitfield in a c struct as such:
struct Example
{
int A;
int B;
int C : 3;
int D : 3;
int E : 3;
int F : 8;
bool G : 1;
bool H : 1;
};
Would the correct binding in Nim be as such?
type Example {.packed, importc: "Example", "example.h".} = object
a {.importc: "a".} : int32
b {.importc: "b".} : int32
c {.bitsize: 3, importc: "c".} : int32
d {.bitsize: 3, importc: "d".} : int32
e {.bitsize: 3, importc: "e".} : int32
f {.bitsize: 8, importc: "f".} : int32
g {.bitsize: 1, importc: "g".} : bool
h {.bitsize: 1, importc: "h".} : bool
or as such?
type Example {.importc: "Example", "example.h".} = object
a {.importc: "a".} : int32
b {.importc: "b".} : int32
c {.importc: "c".} : int32
d {.importc: "d".} : int32
e {.importc: "e".} : int32
f {.importc: "f".} : int32
g {.importc: "g".} : bool
h {.importc: "h".} : bool
Does the {.packed.}
pragma align on the byte? Is the {.packed.}
pragma even required here because I am importing from C?