[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
A question about the data type of rtems
- Date: Mon, 13 Oct 2008 14:36:29 +0200
- From: ralf.corsepius at rtems.org (Ralf Corsepius)
- Subject: A question about the data type of rtems
On Mon, 2008-10-13 at 20:14 +0800, PowerMan wrote:
> 1. In which file "uint32_t" is defined ?
stdint.h
> 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.
Almost.
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.
Ralf