spacewrench wrote on Friday, August 14, 2009:
Yes, within the compilation of any set of files that are to be linked together successfully, the data types will be of fixed (and equal) lengths. (That is, all portCHARs will be the same size, which is usually 8 bits. All portSHORTs will be the same size, and usually 16 bits, etc.)
The reason these are defined and used is so that you can change/fix things in one place if necessary. I’m not a C/C++ standards expert, but I think the rule on integral sizes is something like sizeof(char)<=sizeof(short)<=sizeof(int)<=sizeof(long). So theoretically, a char could be the same size as a long. This would cause problems for code that assumed that a short always has at least 16 bits. However, since FreeRTOS uses portSHORT everywhere, you can #define or typedef that to be whatever type causes the compiler to give you at least 16 bits.