Sizes of data types

The 32- and 64-bit versions of QNX Neutrino use different C Language Data Type Models:

The sizes of the basic data types are as follows:

Data type 32-bit 64-bit
char 8 8
int 32 32
long 32 64a
long long 64 64
off_t signed 32 signed 64b
paddr_t unsigned 32 unsigned 64b
ptrdiff_t 32 64
short 16 16
size_t, ssize_t 32 64
time_t unsigned 32 signed 64b
uintptr_t, intptr_t 32 64
void * 32 64

a 64-bit Windows uses 32 bits for a long because there's a lot of code that assumes that a long and an int are the same size. 64-bit Unix-type OSs use 64 bits for a long.

b These changes aren't linked to 64-bit addresses, but this is a convenient time to make them.

Many compound types have changed in size, including the following:

When we extended the structures, we defined additional versions for 32- and 64-bits. For example, in addition to struct sigevent, we've defined struct __sigevent32 and struct __sigevent64 that have the correctly sized fields. These additional types let you access—for example—the 32-bit structure in a program compiled for 64 bits. The fields might not be of the same type as in the original structure, but they'll be the correct size.

Because of all these changes, you need to be careful with data types. For example:

You can use the PRI* macros that are defined in <inttypes.h> to simplify calls to printf() that involve integers whose conversion specifier is different in 32- and 64-bit architectures.

Note: You can use the -Wconversion compiler option to generate warnings about any implicit conversions that could alter a value. This option isn't enabled by -Wall or -Wextra, so you have to specify it explicitly. For more information, see the gcc documentation at https://gcc.gnu.org/onlinedocs/gcc/.