tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: in which we present an ugly hack to make sys/queue.h CIRCLEQ work
> In gcq.h, I used (uint8_t *) instead of (char *) with offsetof and I
> see endian.h uses unit8_t to rearrange bytes. It makes more sense
> that way IMO, but it sounds like it actually violates strict aliasing
> while using char wouldn't.
There are two possible issues here.
The first is whether uint8_t exists. If it doesn't exist, the code
won't even build; if it does exist, it can't be larger than char,
because CHAR_BIT must be at least 8, and it can't be smaller, because
sizeof(char) is by definition 1 and thus no type can be smaller.
However, even if it does exist and is the same size as char, I see no
reason it has to be `a character type' - different integral types of
the same size can exist, as (for example) on current 32-bit machines
where int and long are identical in size and representation but are
nonetheless distinct types. I know of nothing that forbids the
existence of an integral type the same size as char but not a character
type, though such a thing could exist and I just missed it.
Of course, pragmatically, it is highly unlikely uint8_t will be
anything but unsigned char, so you are almost certain to be OK in
practice.
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse%rodents-montreal.org@localhost
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
Home |
Main Index |
Thread Index |
Old Index