C++ uint32 和 uint32_t 的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13362084/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Difference between uint32 and uint32_t
提问by Maxbester
Possible Duplicate:
Difference between different integer types
可能的重复:
不同整数类型之间的差异
What is the difference between uint32 and uint32_t in C/C++?
C/C++ 中的 uint32 和 uint32_t 有什么区别?
Are they OS dependent?
它们是否依赖于操作系统?
In which case should I use one or another?
在哪种情况下我应该使用一种或另一种?
Thanks
谢谢
回答by William Pursell
uint32_t
is standard, uint32
is not. That is, if you include <inttypes.h>
or <stdint.h>
, you will get a definition of uint32_t
. uint32
is a typedef in some local code base, but you should not expect it to exist unless you define it yourself. And defining it yourself is a bad idea.
uint32_t
是标准的,uint32
不是。也就是说,如果您包含<inttypes.h>
或<stdint.h>
,您将获得 的定义uint32_t
。 uint32
是一些本地代码库中的 typedef,但除非您自己定义它,否则您不应期望它存在。自己定义它是一个坏主意。
回答by Luchian Grigore
uint32_t
is defined in the standard, in
uint32_t
在标准中定义,在
18.4.1 Header <cstdint>
synopsis [cstdint.syn]
18.4.1 标题<cstdint>
概要 [cstdint.syn]
namespace std {
//...
typedef unsigned integer type uint32_t; // optional
//...
}
uint32
is not, it's a shortcut provided by some compilers (probably as typedef uint32_t uint32
) for ease of use.
uint32
不是,它是一些编译器(可能是typedef uint32_t uint32
)为便于使用而提供的快捷方式。