Timeline for Why were short, int, and long invented in C?
Current License: CC BY-SA 3.0
17 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 7, 2014 at 3:28 | comment | added | John R. Strohm | @Mehrdad, there are platforms where the obvious choice for short is NOT 2x sizeof(char). The Harris 24-bit superminicomputers come immediately to mind. Some PICs and some DSPs have similar characteristics. | |
May 6, 2014 at 23:33 | answer | added | supercat | timeline score: 6 | |
Aug 28, 2012 at 15:20 | comment | added | alx9r | In embedded systems I've seen a fairly common convention to typedef long, short, and int to the form int16_t and defining constants like MAX_INT16 so that you have a hope of targeting multiple processors from the same code base. Once you do that, you can ignore the ambiguity of short, int and long. | |
Nov 12, 2011 at 8:33 | vote | accept | user541686 | ||
Oct 30, 2011 at 7:16 | vote | accept | user541686 | ||
Oct 30, 2011 at 7:16 | |||||
Oct 21, 2011 at 3:08 | comment | added | detly |
HiTech's C compiler for Microchip's PIC16F* family had a size for an long short int ... it was 24 bits.
|
|
Oct 20, 2011 at 18:28 | comment | added | SK-logic |
There are platforms where sizeof(char) == sizeof(short) , and it makes sense. Unfortunately, there is no way to specify integral number types that way that they'll fit all the possible and existing platforms.
|
|
Oct 20, 2011 at 17:39 | comment | added | user541686 |
@SK-logic: Not even if they said sizeof(short) == 2 * sizeof(char) or similar?
|
|
Oct 20, 2011 at 15:01 | comment | added | SK-logic | C was meant to be both portable and close to the underlying hardware. There were platforms where byte was not 8 bit long - but you still could use C. No fixed set of data types would ever be sufficient, no fixed size integere could ever be portable. | |
Oct 20, 2011 at 14:54 | answer | added | kylben | timeline score: 1 | |
S Oct 20, 2011 at 3:22 | history | suggested | yoozer8 | CC BY-SA 3.0 |
Fixed the title
|
Oct 20, 2011 at 3:13 | review | Suggested edits | |||
S Oct 20, 2011 at 3:22 | |||||
Oct 20, 2011 at 3:08 | comment | added | user541686 | @BlackJack: Haha yes I actually have -- but I guess my question is, why aren't all those types defined natively instead? Is it a "hindsight is 20/20" issue, or was there a specific reason? | |
Oct 20, 2011 at 2:45 | answer | added | Jeff Grigg | timeline score: 4 | |
Oct 20, 2011 at 2:25 | comment | added | BlackJack |
Check out <stdint.h>
|
|
Oct 20, 2011 at 1:26 | answer | added | user28988 | timeline score: 13 | |
Oct 20, 2011 at 1:05 | history | asked | user541686 | CC BY-SA 3.0 |