E
EricFowler
Sorry if this is a FAQ, I could not find it.
I am writing C code that will be reading data of fixed format from
devices. The format of this data is constant and beyond my control and
comprises 8, 16, and 32 bit signed and unsigned values.
I wish to write C code that will compile on all (well, many)
platforms, and will have properly sized variables. The problem is in
declaring a variable that is always (say) 16 unsigned bits.
A first cut is to use __uint16_t , but I have been having a hard time
defining that variable. It is supposedly in stdint.h but when I
include that file, the type is undefined.
I have noticed that when I include stdio.h, the type is found, but I
don't want that header everywhere.
What is the simple standard way to define a variable of fixed bit
size?
Don't worry about endianess; I will deal with that separately.
Thanks
Eric
I am writing C code that will be reading data of fixed format from
devices. The format of this data is constant and beyond my control and
comprises 8, 16, and 32 bit signed and unsigned values.
I wish to write C code that will compile on all (well, many)
platforms, and will have properly sized variables. The problem is in
declaring a variable that is always (say) 16 unsigned bits.
A first cut is to use __uint16_t , but I have been having a hard time
defining that variable. It is supposedly in stdint.h but when I
include that file, the type is undefined.
I have noticed that when I include stdio.h, the type is found, but I
don't want that header everywhere.
What is the simple standard way to define a variable of fixed bit
size?
Don't worry about endianess; I will deal with that separately.
Thanks
Eric