2 ms·
Because 32/32 architectures (32-bit registers, 32-bit address space) became dominant for a long time. I'm referring to the 386, 68k, and the common 32-bit ARMs.
by userbinator 3y ago
Because 32/32 architectures (32-bit registers, 32-bit address space) became dominant for a long time. I'm referring to the 386, 68k, and the common 32-bit ARMs.
I still remember the era when int was usually 16 bits and you needed a long to get 32. This is still true for smaller embedded systems.
- SV_BubbleTime 3y agoPIC micros man, int was 8bits for me like… 13 years ago.
- jcranmer 3y agoC does require that int is at least 16 bits (e.g., INT_MAX has to be at least 32767).
- SAI_Peregrinus 3y agoISO C requires that. PIC C doesn't. There aren't that many C dialects, but there are a few.
- Findecanor 3y agoYou can often override that to be 8-bit on compilers for 8-bit microcontrollers, on which C's integer promotion rules to 16 bits can be costly. I'd think that while a good compiler should be able to optimise those away, even a good programmer might not always write code that provides the compiler with the hints to do that.
- kristopolous 3y agomost arduino is 16-bit int, right now, except when it's not. good luck.
- ack_complete 3y agoIn the other direction, Lattice C used 32-bit ints on the 68000, where 16-bit was more efficient. This led to a bunch of code explicitly using short instead of int, and then later being converted back to int for later platforms -- sometimes with amusing results, like a comment labeling an error code as meaning "the buffer is too int."
- cozzyd 3y agoSometimes you need double buffering