Use fixed integer types to enhance portability
If you have programmed anything with C, you should be familiar with common data types like char, unsigned char, int, unsigned int, long int, long long int, etc. It is tough to tell by the looks of the type how many bytes this variable takes on memory and how it looks in a different system. For instance, in 8-bit AVR-GCC compiler, int is a 16-bit type, while in ARM-GCC, int is 32-bit. So int size is dependent on platform, compiler, and runtime libraries. And switching between systems may trick you if you are not careful enough. You can always check the size of the variable by using sizeof() function. What to do if you need your code to be portable between different systems. Some great libraries could work on any system, including 8-bit, 16-bit, 32-bit, or 64-bit. To avoid this annoying problem, the ISO C99 standard introduced portable data types that are defined in stdint.h header file. If you open this header file of your default compiler tool-set you will find how things are organized. First of all, it checks…