[EXTERNAL]: Re: Why int32_t is long int on 32 Bit Intel?

Stefan Tauner stefan.tauner@gmx.at
Sat Jul 29 13:19:58 GMT 2023


On Sat, 29 Jul 2023 08:47:22 -0400
Trampas Stern <trampas@gmail.com> wrote:

> Most code and libraries, like FAT libraries, all assume a char is 8bit.

Well, it's mandated by POSIX to be 8 bits and in general a quite
reasonable assumption (if targeting POSIX systems) but not necessarily
true elsewhere... and if you depend on the signedness of char you are
doing it wrong too. If you want 8 unsigned bits you should use uint8_t
instead of char. In that regard it's quite similar to the int
"problem". In either case there is a proper solution in C that is
working on all conforming systems.

> right shift sign extended.

Right shifts of negative integers is UB in C (and not necessarily
sign-extended) if that's what you mean. We are also quite off-topic
already IMHO...

-- 
Kind regards/Mit freundlichen Grüßen, Stefan Tauner


More information about the Newlib mailing list