length of integral portCHAR portSHORT…

Just wondering if all integral data type, such as portCHAR portSHORT portLONG are of fixed length. I supposed them to be yes. For example, portCHAR always 8bits, portSHORT always 16bit and portLONG always 32bits, is that true? Thanks.

length of integral portCHAR portSHORT…

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.

length of integral portCHAR portSHORT…

and what about this portBASE_TYPE? this seems not to be of fixed length, looks like size_t, correct?

length of integral portCHAR portSHORT…

Look right at the bottom of this page: http://www.freertos.org/a00017.html#DataTypes As has already been said, portSHORT is always 16 bits and portLONG is always 32 bits.  int is never used.  The kernel code uses these definitions in any source file that is compiled for all processors (8, 16 and 32bits), so the kernel code and the common demo code uses them.  Your application code does not need to use them unless you want it to be portable across 8, 16 and 32bit architectures too. portBASE_TYPE is generally used for Boolean values and is set to whatever is the most efficient type for the architecture.  Generally this is a char for 8 bitters, short for 16 bitters and long for 32 bitters. portTickType can be 16 or 32 bits, but it would be very odd to use 16 bits on a 32 bit architecture. Regards.

length of integral portCHAR portSHORT…

perhaps further silly question, how do you find the size of standard data type for each compiler? did you test all data type by sizeof(standard type) for each compliler? or by look at the docs of the compiler? Many thanks.

length of integral portCHAR portSHORT…

I don’t know what people generally do, but I might do it either way, depending on what I’m doing and why I want to know.  If I’m writing code (so I have my editor, compiler and a test board all ready) I’ll do main () { printf( "%dn", sizeof(int) ); }.  (But that’s uncommon; if I’m writing code, I usually have a pretty good idea of the datatypes the target supports, and how to specify them to the compiler.)  OTOH, if I don’t have a dev environment set up, then it’s unlikely that I’d need to know in the first place, but if I did, I’d check the compiler docs. It’s not worth my time to go idly inquiring into various compilers’ default integer sizes on assorted MCUs, though.  There’s always a way to get the compiler to use the type you want, or the compiler isn’t worth wasting time on.

length of integral portCHAR portSHORT…

glad to see the auther of FreeRTOS wondering that why you choosed to publish your code to be  free to open source rather than like uCos which is not free even source open. This might be personal question, there is no abligation to answer. Secondly, could you please explain what tools you used to test your code, such as static tools Lint, and dynamic tools CUnit, or even more expensive testing tools( but I supposed you not using it to develop the open soure). Many thanks.