> > BTW, I've seen processors where char is 32 bit.

The storage allocation of a char may be 16-bits, 32-bits or whatever, with
only 8-bits actually being used.
However the ANSI definition of sizeof(char) is that it always returns 1.
This can lead to nasty problems if you say malloc N bytes to hold N chars
.... even if you try to be decent and use sizeof(char) when calling the
malloc!

Even worse: if you allocate RAM for some chars, where the char is say
32-bits, and then zero the bottom 8-bits ... but the top 24-bits are filled
with junk, then checking the char against 0 can fail, because a 32-bit
instruction might be used.

This nastiness has only caught me out with certain DSPs which have limited
support for byte sized data.

regards,

Richard





Reply via email to