2

From Using the FreeRTOS Real Time Kernel - Standard Edition, p143, I noticed that:

int types are never used – only long and short

I would like to know why, but I find no answer in its official site and no result after google.

Update 08/31:

Maybe my question is not so clear, in short, I just wonder that why FreeRTOS defines BaseType_t as long instead of int(and other FreeRTOS defined types are never use int, too). From its Coding-Standard-and-Style-Guide page, it said that:

BaseType_t

This is defined to be the most efficient, natural, type for the architecture. For example, on a 32-bit architecture BaseType_t will be defined to be a 32-bit type. On a 16-bit architecture BaseType_t will be defined to be a 16-bit type. If BaseType_t is define to char then particular care must be taken to ensure signed chars are used for function return values that can be negative to indicate an error.

From the above description, I think int is more suitable than long, since int is always conform to the architecture's word size.

cifer
  • 615
  • 1
  • 9
  • 25

2 Answers2

3

The FreeRTOS coding standard disagrees with your reference.

The actual requirement is that you use typedefs that have been defined by RTOS, or the integer typedefs found in stdint.h, such as uint32_t. Normally, the types found in stdint.h are acceptable, because the size of those integers do not vary on different architectures.

Bill Lynch
  • 80,138
  • 16
  • 128
  • 173
  • Sorry but I don't find disagrees between the link you supplied and my reference, please say my updates above – cifer Aug 31 '15 at 05:39
  • @Cifer: Quoting you: _From the above description, I think int is more suitable than long, since int is always conform to the architecture's word size._ That's just not true. – Bill Lynch Sep 01 '15 at 03:31
0

Not an official answer by any means, by I would suppose they wanted to make sure their types are clearly defined, and therefore decided on 3 int types: char (uint8_t), short (unit16_t) and long (uint32_t). This way any confusion as to what's the size of int is avoided.

uri2x
  • 3,162
  • 1
  • 11
  • 25
  • None of the types you mentioned has to have that corresponding fixed size type. – edmz Aug 30 '15 at 18:26
  • @black according to [FreeRTOS Coding Standard and Style Guide](http://www.freertos.org/FreeRTOS-Coding-Standard-and-Style-Guide.html) these are clearly defined fixed size types. They just had to come up with 3 names for the 3 types, and found that `int` would be too confusing to use for one of them. – uri2x Aug 31 '15 at 06:12