I'm seeking for a macro representing the maximum value of uint64_t
as UINT_MAX
is for unsigned int
.
i.e. I need this value to guaranteed to be (1<<64)-1.
I tried to use UINT64_MAX
, but compiling with g++ results in:
'UINT64_MAX' was not declared in this scope
It's worth to mention that I have this line #define __STDC_LIMIT_MACROS
in the code before using UINT64_MAX
.
I was surprised to not find helpful information around the web about it.
Using the cstdint
header portably can be quite a challenge (it is missing from some MSVC implementations). At the same time numeric_limits::max()
can be hard to use without constexpr
and it is not actually required to work with uint64_t
. If you don't care about those things too much, std::numeric_limits<uint64_t>::max()
will most likely do the trick.
Boost.Integer has an implementation of cstdint
and comes with an extra traits class to get a constant maximal value. A compliant implementation of cstdint
should also provide the macro UINT64_MAX
, but I'm not sure about boost.