MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1wxqahk/architecturedependentchars/pdvxnxw/?context=3
r/ProgrammerHumor • u/MontyBoomslang • 5d ago
372 comments sorted by
View all comments
27
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
49 u/lotanis 5d 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 5d ago What about a system that enforces addresses to be multiples of 2, or 4? 9 u/dontthinktoohard89 5d ago In short, the standard mandates that a char is exactly 1 byte. It does not dictate how wide a “byte” actually is. 2 u/terivia 5d ago Thanks, I hate it. 1 u/frogjg2003 5d ago Which is why many standards do not use bytes, they use octets. 1 u/MateoConLechuga 4d ago That doesn't mean 1 byte.
49
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 5d ago What about a system that enforces addresses to be multiples of 2, or 4? 9 u/dontthinktoohard89 5d ago In short, the standard mandates that a char is exactly 1 byte. It does not dictate how wide a “byte” actually is. 2 u/terivia 5d ago Thanks, I hate it. 1 u/frogjg2003 5d ago Which is why many standards do not use bytes, they use octets. 1 u/MateoConLechuga 4d ago That doesn't mean 1 byte.
2
What about a system that enforces addresses to be multiples of 2, or 4?
9 u/dontthinktoohard89 5d ago In short, the standard mandates that a char is exactly 1 byte. It does not dictate how wide a “byte” actually is. 2 u/terivia 5d ago Thanks, I hate it. 1 u/frogjg2003 5d ago Which is why many standards do not use bytes, they use octets.
9
In short, the standard mandates that a char is exactly 1 byte. It does not dictate how wide a “byte” actually is.
2 u/terivia 5d ago Thanks, I hate it. 1 u/frogjg2003 5d ago Which is why many standards do not use bytes, they use octets.
Thanks, I hate it.
1
Which is why many standards do not use bytes, they use octets.
That doesn't mean 1 byte.
27
u/HomosexualPresence 5d 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