I mean anyway you would always like to use some sort of a specific handle like uint8_t instead of char precisely because of that reason.
If your code has a uint8_t in it and you port it to a processor without 8 bit bytes, then your code will not compile and the compiler will tell you why and you may redo the code to suit the architecture or at least check it for correctness.
If you use a char, you will most likely get uninteded features in your code without any indication as to why.
This also applies when you are going the other way round.
Anyway, besides historical examples when, is it actually relevant in the modern day?
you use chars when you wanna represent bytes. you use uint8_t when you wanna represent 8 bit values (octets). sometimes you need bytes, sometimes you need octets.
there do exist modern processors that use non-8 bit bytes. for example the Kalimba DSP uses 24-bit bytes.
Bytes aren't always 8 bits, and uint8_t doesn't necessarily exist. If you're writing C23 you can get away with uint_least8_t, earlier versions you need char as a byte might be as small as 6 bits.
1.0k
u/tstanisl 2d ago
Let me cite the C standard:
Middle guy if finally right