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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 17:14:27  来源:igfitidea点击:

Difference between uint32 and uint32_t

c++cuint32uint32-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_tis standard, uint32is not. That is, if you include <inttypes.h>or <stdint.h>, you will get a definition of uint32_t. uint32is 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_tuint32是一些本地代码库中的 typedef,但除非您自己定义它,否则您不应期望它存在。自己定义它是一个坏主意。

回答by Luchian Grigore

uint32_tis 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
//...
}

uint32is not, it's a shortcut provided by some compilers (probably as typedef uint32_t uint32) for ease of use.

uint32不是,它是一些编译器(可能是typedef uint32_t uint32)为便于使用而提供的快捷方式。