C help on 64/32 bit integers.
Kurt Wall
kwall
Thu Feb 16 21:22:26 PST 2006
On Tue, Feb 14, 2006 at 08:42:59AM -0600, Ben Duncan took 28 lines to write:
> Ok, my MVISAM databse is starting to take shape. I do need, however,
> to determine weather or not it is compiled on a 64 or a 32 bit cpu platform.
>
> I have some RECORD headers that the "int" values need to stay at 32 bits
> for determining record size (not the off_t for record access). Hey, if
> you have ONE record that's greater than 2GB, don't call me !! ;-> ..
>
> Anyway, I have segregated "FILE ACCESS" pointers and "record location"
> (where inside of the current record I am) pointers. The Record Location
> pointers need to stay 32 bits regardless of the platform.
No, what you need is a 32-bit type, not whether or not your machine has
been compiled on a 32- or 64-bit machine. The C standard does not make
absolute size guarantees, only that
sizeof(char) <= sizeof(int) <= sizeof(long)
If your code depends on type-sizing and isn't in the kernel, it is by
definition broken.
Failing that, if you need specific integer sizes, use the typdefs in
stdint.h:
int8_t
uint8_t
int16_t
uint16_t
int32_t
uint32_t
int64_t
uint64_t
Kurt
--
Fashion is a form of ugliness so intolerable that we have to alter it
every six months.
-- Oscar Wilde
More information about the Linux-users
mailing list