我们对某些类型参数使用模板专门化,例如
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> {
....
}
这与 gcc 的 64 位编译完美配合。而当我们尝试 32 位模式时,它会报告上述两个类的“先前定义”。
So unsigned long long
是相同的uint64_t
在 32 位编译中可以,但在 64 位编译中不行?
编译差异是CXX
flag -m32
and -m64
So unsigned long long
是相同的uint64_t
在 32 位编译中可以,但在 64 位编译中不行?
Yes.
在 32 位模式下,很可能long
是 32 位并且long long
是64位的。在 64 位模式下,两者可能都是 64 位。
在 32 位模式下,编译器(更准确地说是<stdint.h>
标头)定义uint64_t
as unsigned long long
, 因为unsigned long
不够宽。
在64位模式下,它定义uint64_t
as unsigned long
.
It could将其定义为unsigned long long
在两种模式下。选择是任意的;所要求的只是它必须是 64 位类型。
一般来说,每个整数类型定义在<stdint.h>
是具有适当特征的某些预定义类型的 typedef。您不能假设它们中的任何一个与预定义类型不同。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)