Is the following code legal?
struct BigInt {
uint64_t a : 128;
};
A bitfield must fit within a single int
, so you're out of luck unless int
is 128 bits on your platform.
(You were also missing a ;
at the end of the struct
prior to the edit.)
Not legal in standard C11 (on most platforms; in principle, an int
might be 128 bits, but I never met a platform having that). Read n1570 (draft specification).
But on some platforms recent compilers (e.g. GCC 6) provide __int128
as an extension. You won't use that as a bitfield, but as some kind of integral type.
See also this answer to a related question.