I have an open-source codebase that is written in both C and C++. I\'m looking for an integer type that is guaranteed to be at least 64 bits wide, which can be reli
Is the general suggestion to use
int64_t
in place oflong long
, when portability is an important goal?
I'd be very surprised if a compiler offered int64_t
but not long long
.
If long long
is present, it must have at least 64 bits, so casting from (u)int64_t
to (unsigned) long long
is value-preserving.
If you need a type with exactly 64 bits, use (u)int64_t
, if you need at least 64 bits, (unsigned) long long
is perfectly fine, as would be (u)int_least64_t
.