H.Merijn Brand wrote:
>2. It just tests on UCHAR_MAX == 255 (what if 9bit-byte systems don't
> have limits.h or don't define UCHAR_MAX ?
If you're actually running (rather than just compiling or preprocessing)
code for this test, you might as well be empirical about it:
#include <stdio.h>
int main(void) {
int n;
unsigned char c;
for(c=1, n=0; c; c<<=1, n++) ;
printf("CHAR_BITS=%d\n", n);
return 0;
}
The arithmetical behaviour of unsigned char is sufficiently guaranteed
by the C standard for this to always be correct.
-zefram
Thread Previous