Tag: cstdint

我应该使用cstdint吗?

我一直在思考我是否应该使用<cstdint>的typedef。 我个人比较喜欢把uint32_t写在unsigned int和int8_t上,因为它对我来说更直观。 你们有什么感想? 使用来自<cstdint>的types定义是不是一个好主意? 有什么缺点吗?

'uint32_t'没有命名一个types

我试图编译一个在2007年编写的C ++软件包,我得到这个错误: error: 'uint32_t' does not name a type 这发生在使用g ++ 4.5.2的64位Ubuntu上。 它在使用g ++ 4.1.2的64位CentOS上编译得很好。 有没有一个#include或编译器国旗,我失踪了? 或者,我应该使用typedef将uint32_t分配给size_t或者可能是一个unsigned int ?

C ++:long long int长整型与int64_t

我在使用C ++types特征的时候遇到了一些奇怪的行为,并且把我的问题缩小到了这个古怪的小问题上,我会给出很多的解释,因为我不想留下任何可能导致误解的东西。 假设你有这样一个程序: #include <iostream> #include <cstdint> template <typename T> bool is_int64() { return false; } template <> bool is_int64<int64_t>() { return true; } int main() { std::cout << "int:\t" << is_int64<int>() << std::endl; std::cout << "int64_t:\t" << is_int64<int64_t>() << std::endl; std::cout << "long int:\t" << is_int64<long int>() << std::endl; std::cout << "long long int:\t" […]

<cstdint> vs <stdint.h>

stdint.h和cstdint什么cstdint ? 它们都可以在MSVC(Visual Studio 2010)和gcc-4.5.1中使用。 还要定义intX_t / uintX_ttypes(其中X是types的字节大小)。 如果两个头文件中的基本原理是相同的(便携式),那么我必须做出什么决定来决定哪一个呢? stdint.h定义了没有任何名称空间的每个types, cstdinttypes位于std名称空间中。 是否有任何理由包含或不包括定义的types到std命名空间? 两个标题有什么不同? cstdint没有文件扩展名并使用c前缀, stdint.h使用.h扩展名。 这个头文件的命名约定是什么? c前缀表示这是一个C库? 在cstdint缺less文件扩展的cstdint什么?