On Friday, 3 May 2013 at 01:03:39 UTC, bearophile wrote:
Jeremy DeHaan:
D bools are 1 byte, and C/C++ chars are 1 byte as well and it
works.
D bools are 1 byte, but C chars don't need to be 1 byte, so you
are working with an implementation detail.
Technically speaking, you are right. Generally speaking, it's
probably going to be pretty rare for a compiler these days to
define a char type as more the 8 bits so I figured I would be
safe.
I think in C99+ it's better to use uint8_t from stdint.h,
that's safely always 1 byte long.
I agree with you on this though, and it is definitely a better
solution. Question though, is there any difference between uint_t
and int8_t for this kind of purpose? They are the same size, but
the former is just unsigned.