C语言 是否在任何 stdlib 标头中定义了 uint32、int32、uint64、int64 等类型?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6013245/
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
Are types like uint32, int32, uint64, int64 defined in any stdlib header?
提问by philix
I often see source code using types like uint32, uint64 and I wonder if they should be defined by the programmer in the application code or if they are defined in a standard lib header.
我经常看到使用 uint32、uint64 等类型的源代码,我想知道它们是否应该由程序员在应用程序代码中定义,或者是否应该在标准 lib 头文件中定义。
What's the best way to have these types on my application source code?
在我的应用程序源代码中使用这些类型的最佳方法是什么?
回答by mu is too short
The C99 stdint.hdefines these:
C99stdint.h定义了这些:
int8_tint16_tint32_tuint8_tuint16_tuint32_t
int8_tint16_tint32_tuint8_tuint16_tuint32_t
And, if the architecture supports them:
并且,如果架构支持它们:
int64_tuint64_t
int64_tuint64_t
There are various other integer typedefs in stdint.has well.
还有各种其他整数类型定义stdint.h。
If you're stuck without a C99 environment then you should probably supply your own typedefs and use the C99 ones anyway.
如果您在没有 C99 环境的情况下陷入困境,那么您可能应该提供自己的 typedef 并无论如何都使用 C99 的。
The uint32and uint64(i.e. without the _tsuffix) are probably application specific.
该uint32和uint64(即不带_t后缀)可能是特定应用。
回答by GWW
Those integer types are all defined in stdint.h
这些整数类型都定义在 stdint.h
回答by BiGYaN
If you are using C99 just include stdint.h. BTW, the 64bit types are there iff the processor supports them.
如果您使用的是 C99,只需包含stdint.h. 顺便说一句,如果处理器支持它们,则存在 64 位类型。
回答by Steve
The questioner actually asked about int16 (etc) rather than (ugly) int16_t (etc).
提问者实际上问的是 int16(等)而不是(丑陋的)int16_t(等)。
There are no standard headers - nor any in Linux's /usr/include/ folder that define them without the "_t".
没有标准头文件——Linux 的 /usr/include/ 文件夹中也没有标准头文件来定义它们而不带“_t”。

