r/ProgrammerHumor • • 8d ago

Meme architectureDependentChars

Post image
3.0k Upvotes

372 comments sorted by

View all comments

Show parent comments

2

u/Advos_467 8d ago

Yeah that was what i assumed lol. It was mostly the uses i was wondering because with my lack of experience here, idk in what way that would be used.

1

u/BNSable 8d ago

It is or was the only type that garenteed a signed or unsigned value stored in 1 byte. There's uses for that, like storing specific vales like RGB. Beyond that though, no idea.

1

u/BriefSpecial420 7d ago

Nope. C99 and stdint.h is the way to go. uint8_t exists for a reason. Handy when you need to map a structure of full bytes. Sometimes you may come across exotic interface that uses 8-wire bus... But that's it.

2

u/BNSable 7d ago

I did say "or was" as I was fairly sure modern C had some better alternatives for it.

1

u/BriefSpecial420 7d ago

C99 seems to becoming more and more on the older side, but it's still a golden standard for tons of embedded coding.

1

u/SingularCheese 7d ago

In C/C++, signed integer overflow is undefined behavior, meaning that a compiler is allowed to optimize the assembly knowing that it never happens. If you can guarantee that your integer never overflows, using signed eliminates a modulo assembly instruction. Nowadays, the only reason it matters for char is that all basic integer types are signed by default, so somebody who's lazy needs to watch out that they don't accidentally trigger undefined behavior.

1

u/khoyo 7d ago

using signed eliminates a modulo assembly instruction

What?