Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

sizeof(char) is implementation defined; see limits.h for more information on the probable size of char for your target. If the sizeof(char) is 1, the division will be optimized away, so there's no loss by keeping the code portable.


No, the size of char (in bits) is implementation defined, but sizeof(char) is defined to be 1, no matter what its size in bits.


No this is incorrect, see:

http://stackoverflow.com/q/4562249/25981

sizeof(char) is always defined to be one. This can't be altered by a conforming compiler.


Wrong. sizeof(char) is define to be one. The number of bits in a byte (char) is implementation defined (this is why CHAR_BIT exists). Not the same thing.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: