Hacker News new | past | comments | ask | show | jobs | submit login

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.



Yeah 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


I 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.


That'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.


The 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.


Several DSPs don’t use 8 bit chars

https://stackoverflow.com/a/2098444




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: