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 really hard to tell by looks of type how many bytes this variable takes on memory and how it looks in different system. For instance in 8-bit AVR-GCC compiler int is 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 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, … Continue reading