Andy said:
I was wondering how to compile an int into 64bit mode in a 64 bit
machine with gcc. Seems by default the int is treated as 4bytes.
There may or may not be a way to cause the compiler to use 64 bits
for type int. Consult your gcc documentation.
Note that if int is 64 bits, and char is 8 bits, then short is
probably either 16 bits or 32 bits; either there's no 16-bit
predefined type, or there's no 32-bit predefined type (unless the
implementation provides extended integer types).
But why do you want to do this? If your code thinks int is 64 bits,
it won't be able to interface with any outside code (including
the OS and the standard library) that assumes int is 32 bits --
unless the OS provides 64-bit-int libraries, but it probably doesn't.
If you want a 64-bit integer type, you almost certainly have one;
it's just not called "int". "long long", if you're using gcc in a
mode where it recognizes it, is guaranteed to be at least 64 bits.
"long", like "int", *could* be 64 bits, but is only guaranteed to
be at least 32 bits. int64_t, defined in <stdint.h> or <inttypes.h>
if you have those headers, is guaranteed to be exactly 64 bits.