unsigned long long conflict with uint64_t?
unsigned long long conflict with uint64_t?
我们对一些类型参数使用模板特化,比如
class my_template_class<uint64_t M>: public my_template_class_base<uint64_t> {
....
}
class my_template_class<unsigned long long,M>: public my_template_class_base<unsigned long long> {
....
}
这是完美的64位编译与gcc。而当我们尝试32位模式时,它会报告以上两个类的"先前定义"。
所以unsigned long long
在32位编译中与uint64_t
相同,但在64位编译中却不同?
编译的区别是CXX
标志-m32
和-m64
所以
unsigned long long
在32位编译中与uint64_t
相同,但在64位编译中不一样?
是的。
在32位模式下,long
最有可能是32位,long long
是64位。在64位模式下,两者可能都是64位。
在32位模式下,编译器(更准确地说是<stdint.h>
头文件)将uint64_t
定义为unsigned long long
,因为unsigned long
不够宽。
在64位模式下,将uint64_t
定义为unsigned long
。
它可以在两种模式下都将其定义为unsigned long long
。选择是任意的;所需要的只是它必须是64位类型。
一般来说,<stdint.h>
中定义的每个整数类型都是具有适当特征的预定义类型的typedef。您不能假设它们中的任何一个与预定义类型不同。
这是来自stdint.h
的GCC 4.8:
#if __WORDSIZE == 64
typedef unsigned long int uint64_t;
#else
__extension__
typedef unsigned long long int uint64_t;
#endif
:
所以unsigned long long在32位复杂度中与uint64_t相同,而不是在64位复杂度中?
是的。
相关文章:
- 如何在 C 中正确使用 libiconv 使其不会报告"Arg list too long"?
- 不能在初始值设定项列表中将非常量表达式从类型 'int' 缩小到'unsigned long long'
- Problems with std::cin.fail()
- 在C++中使用GDAL可以将图像的像素坐标转换为lat,long吗
- 应用程序崩溃并显示"symbol _ZdlPvm, version Qt_5 not defined in file libQt5Core.so.5 with link time reference"
- <Windows>为什么 std::thread::native_handle 返回类型为"long long unsigned int"的值,而不是 void*(又名 HANDLE)?
- 这对"With a stackless coroutine, only the top-level routine may be suspended."意味着什么
- Boost.TEST with CLion: "Test framework quit unexpectedly"
- 避免碎片化的ClientHellos with OpenSSL (DTLS)
- Issues with Win32 ReadProcessMemory API
- Qt with WinAPI MouseProc
- [[maybe_unused]] with structured_binding?
- Issue with WriteProcessMemory
- OpenCV RTP-Stream with FFMPEG
- "Unable to start debugging. No process is associated with this object." - 在Visual Studio Code中使用GDB
- 错误:隐式转换更改符号:'int'到'unsigned long'
- std::adjacent_difference with std::chrono time_point
- cudaMallocManaged with vector<complex<long double> > C++ - NVIDIA CUDA
- 如何修复错误"long* is incompatible with U32**"?
- unsigned long long conflict with uint64_t?