4 ms·
Challenge: specify a mainstream architecture (e.g. targeted by Debian stable) which doesn't have char=1, short=2, int=4, long long=8 bytes with GCC or Clang.
by ptspts 3y ago
Challenge: specify a mainstream architecture (e.g. targeted by Debian stable) which doesn't have char=1, short=2, int=4, long long=8 bytes with GCC or Clang.
- gpderetta 3y agowell, you skipped long :D
- professoretc 3y agoYeah, skipped the one built-in type that is different between architectures (64-bits on 64-bit Linux, 32-bits on 64-bit Windows).
- gpderetta 3y agoIndeed. And 32-bits on 32-bit Linux of course.
- fooker 3y agoOne major point of divergence is the size and representation of pointers, and people treating pointers as integers. Also floating point formats can vary a bit even with the size being the same. So a piece of code written for one might be subtly wrong for another.
- ColonelPhantom 3y agoAren't pointers pretty much universally 64 bits, except for some old or esoteric machines? And why would you not be able to treat one as an integer? Are there any examples of such ISAs? Finally, floating point formats do differ, but that shouldn't affect anything except precision and binary format. Also I'm pretty sure "float" is standard IEEE 32 bit and "double" is standard 64 bit, with predefined exponent/mantissa sizes. The only thing that could differ between arches is endianness, and by far most ISAs have settled on little endian.
- gpderetta 3y agox86 is hardly esoteric. New software for it is being published today.
- ColonelPhantom 3y agox86_32 counts as an old machine (the most recent CPU being the first generation Intel Atom). It's being dropped left and right in favour of only supporting 64-bit machines (x86_64, aarch64, maybe RV64).
- gpderetta 3y agoCPUs shipped by intel today still support (non exclusively) x86-32. All major OSs (except for MacOS I guess) support running 32bit code along side 64bit code. New 32 bit binaries are created every day. It is hardly legacy yet. Separately, there is also the x32 ABI, although that hasn't really gained any traction.
- pabs3 3y agoHere is the list of Debian architectures and their characteristics: https://wiki.debian.org/ArchitectureSpecificsMemo https://wiki.debian.org/ArchitectureSpecificsMemo It shows that there are no such Debian architectures.
- lionkor 3y agoNot sure why you are focusing on Debian - Windows and Linux have different ideas of how large a long is.