C doesn't define sizes exactly. C types such as int and long are defined as being "at least 16 bits'' and "at least 32 bits'' respectively.
If we want to define variables which have a specific size independent of platform, then we can use types such as int32_t, int64_t defined in sys/types.h header file.
So we would assume that the following code should work:
num = 0xabcdef1234567890;
printf("num = %llx\n", num);
BUT on some platform/compiler combination the output can come out to be 34567890.
Intended O/P: abcdef1234567890
Such as on IBM/AIX, compiler will give a warning
1506-207 (W) Integer constant
<value> out of range.
Whereas GCC/LINUX will print the intended output.
The reason is that the integer literal 0xabcdef1234567890 wasn't explicitly specified to be of type int64_t.
A solution to this is to specify literal as 0xabcdef1234567890LL but a better way of doing this is to use macros in stdint.h (included in inttypes.h)
#include <stdio.h>INT64_C will itself append "LL" or appropriate size specifier to literal depending on platform.
num = INT64_C(0xabcdef1234567890);
printf("num = %" PRIx64 "\n", num);