4 ms·
To be fair writing trully portable C that does useful things is not that simple. When was the last time you made sure your code supports CHAR_BIT != 8 for examp
by temac 3y ago
To be fair writing trully portable C that does useful things is not that simple. When was the last time you made sure your code supports CHAR_BIT != 8 for example.
- optymizer 3y agoI thought that because the C standard requires sizeof(char) to be 1, CHAR_BIT cannot be anything other than 8, unless the architecture is redefining what 'byte' means.
- mtklein 3y agoThat's right, char in C doesn't necessarily mean an 8-bit byte. There are modern architectures where there is no 8-bit type and CHAR_BIT is 16.
- johannes1234321 3y agoThe possibility for a byte to be something other than 8 bit is the reason, why some people refer to 8 bit as octet in network protocols etc. I think I remember somebody pointing to such a machine in some special area (Telco?) still in use in a previous discussion here ... but if that still exists it's very very rare and mostly historical.
- dagmx 3y agoSeveral DSPs don’t use 8 bit chars https://stackoverflow.com/a/2098444 https://stackoverflow.com/a/2098444
- dagmx 3y agoYeah for sure, I just didn’t want to introduce multi-architecture portability since the main issue at hand was intra-arch portability. But yeah, when you get into multiple architectures, it gets gnarly. Take even something as simple as instruction ordering when porting from x86_64 to arm64