Always remember that “size” is a variable unless explicitly stated, so if you declare
int i = 10;
On some systems, this can lead to a 16-bit integer compiler, and for some others, it can lead to a 32-bit integer (or 64-bit integer on newer systems).
In embedded environments, this can end up with strange results (especially when processing I / O with memory mapping or it can be considered as a simple situation with an array), so it is strongly recommended to specify fixed size variables. On legacy systems you may run into
typedef short INT16; typedef int INT32; typedef long INT64;
Starting with C99, designers have added the stdint.h header file, which essentially uses a similar typedef.
On a Windows based system, you can see the entries in the stdin.h header file as
typedef signed char int8_t; typedef signed short int16_t; typedef signed int int32_t; typedef unsigned char uint8_t;
There is more to it than the minimum width value or the exact width of integer types, I think it is nice to study stdint.h for a better understanding.
Naumann Dec 03 '17 at 17:12 2017-12-03 17:12
source share