A question about the data type of rtems

Ralf Corsepius ralf.corsepius at rtems.org
Mon Oct 13 12:36:29 UTC 2008

On Mon, 2008-10-13 at 20:14 +0800, PowerMan wrote:
> 1. In which file "uint32_t" is defined ? 

> 2. Would "int" be different between xxx-rtems-gcc ?
int is defined by the compiler. 

Though it's unlikely to happen, in general, it can not be excluded GCC
might change some internal details on "int".

>   for example, "int" in arm-rtems-gcc is 32-bit,
>    "int" in avr-rtems-gcc is 16-bit.

More precisely: Any presumption on "int" sizes is wrong. 
It's why POSIX invented stdint.h and int<size>_t types.

> 3. If so, I found some driver uses "int",
> Would that make some problems to portability?
Yes, it does.

If your code needs fixed-size types or sizes with guaranteed minimal
sizes, and if you plan to share your code between different
architectures, you're better of using the types from stdint.h and/or
take special precautions on your types (e.g. to not use more than 16bits
of ints to store bitfields).

This is especially important if your code is supposed to be used on
architectures, which come with different flavors of
"8bit/16bit/32bit/64bit/..."-instruction sets.


More information about the users mailing list