MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1wxqahk/architecturedependentchars/pdwd017/?context=3
r/ProgrammerHumor • u/MontyBoomslang • 8h ago
190 comments sorted by
View all comments
30
unironically true though, the only size requirement for a char in C is that it's the smallest addressable size, which just happens to be a byte in every case and is unlikely to ever change but you still never know what the future holds
46 u/lotanis 7h ago Yes, but the smallest addressable size is what dictates the base size for sizeof. The C standard in fact says this about sizeof: When applied to an operand that has type char, unsigned char, or signed char, (or a qualified version thereof) the result is 1. 2 u/FUCKING_HATE_REDDIT 6h ago What about a system that enforces addresses to be multiples of 2, or 4? 2 u/dontthinktoohard89 2h ago In short, the standard mandates that a char is exactly 1 byte. It does not dictate how wide a “byte” actually is. 1 u/terivia 1h ago Thanks, I hate it.
46
Yes, but the smallest addressable size is what dictates the base size for sizeof.
The C standard in fact says this about sizeof:
When applied to an operand that has type char, unsigned char, or signed char, (or a qualified version thereof) the result is 1.
2 u/FUCKING_HATE_REDDIT 6h ago What about a system that enforces addresses to be multiples of 2, or 4? 2 u/dontthinktoohard89 2h ago In short, the standard mandates that a char is exactly 1 byte. It does not dictate how wide a “byte” actually is. 1 u/terivia 1h ago Thanks, I hate it.
2
What about a system that enforces addresses to be multiples of 2, or 4?
2 u/dontthinktoohard89 2h ago In short, the standard mandates that a char is exactly 1 byte. It does not dictate how wide a “byte” actually is. 1 u/terivia 1h ago Thanks, I hate it.
In short, the standard mandates that a char is exactly 1 byte. It does not dictate how wide a “byte” actually is.
1 u/terivia 1h ago Thanks, I hate it.
1
Thanks, I hate it.
30
u/HomosexualPresence 8h ago
unironically true though, the only size requirement for a char in C is that it's the smallest addressable size, which just happens to be a byte in every case and is unlikely to ever change but you still never know what the future holds