You need to make the integer constant of the right type. The problem is that 0x100000000
is interpreted as an int
, and casting / assignment doesn't help: the constant itself is too big for an int
. You need to be able to specify that the constant is of uint64_t
type:
uint64_t Key = UINT64_C(0x100000000);
will do it. If you don't have UINT64_C
available, try:
uint64_t Key = 0x100000000ULL;
You need to make the integer constant of the right type. The problem is that 0x100000000
is interpreted as an int
, and casting / assignment doesn't help: the constant itself is too big for an int
. You need to be able to specify that the constant is of uint64_t
type:
uint64_t Key = UINT64_C(0x100000000);
will do it. If you don't have UINT64_C
available, try:
uint64_t Key = 0x100000000ULL;
In fact, in C99 (6.4.4.1p5):
The type of an integer constant is the first of the corresponding list in which its value can be represented.
and the list for hexadecimal constants without any suffix is:
int
long int unsigned int
long int
unsigned long int
long long int
unsigned long long int
So if you invoked your compiler in C99 mode, you should not get a warning (thanks Giles!).