I have the uint64_t constants in my C++ program (clang 6.0.1 in QtCreator 4.6.1).
For example:
uint64_t a = 0xffffffffffffffffULL;
The problem is, that I get the following warning in the IDE:
Warning: implicit conversion from 'unsigned long long' to 'uint64_t' (aka 'unsigned long')
I tried also to change it to the following without success :
uint64_t a = UINT64_C(0xffffffffffffffff);
uint64_t a = 0xffffffffffffffffUL;
I have options to compute with C++14 standard and option: -Wconstant-conversion
Checking the types size:
std::cout << "uint64_t " << sizeof (uint64_t) << std::endl;
std::cout << "unsigned long " << sizeof (unsigned long) << std::endl;
std::cout << "unsigned long long " << sizeof (unsigned long long) << std::endl;
Result:
uint64_t 8
unsigned long 8
unsigned long long 8
Any idea how to fix this and why IDE thinks that size conversion is happening?
Edit: I just checked the macro expansion:
define UINT64_C(c) c ## UL
This means that provided example should work, however it doesn’t:
uint64_t a = 0xffffffffffffffffUL;