116

令我惊讶的是,我刚刚发现 MS Visual Studio 2003 及更高版本中缺少 C99 stdint.h。我敢肯定他们有他们的理由,但有人知道我在哪里可以下载副本吗?如果没有此标头,我就没有有用类型的定义,例如 uint32_t 等。

4

7 回答 7

84

事实证明,您可以从以下位置下载此标头的 MS 版本:

https://github.com/mattn/gntp-send/blob/master/include/msinttypes/stdint.h

可以在这里找到便携式的:

http://www.azillionmonkeys.com/qed/pstdint.h

感谢Software Rambling的博客。

注意:Michael Burr在评论中提到的标头的公共领域版本,可以在此处找到存档副本。可以在libusb_aah 的 Android 源代码树中找到更新版本。

于 2008-09-24T09:54:09.377 回答
49

只需自己定义它们。

#ifdef _MSC_VER

typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;

#else
#include <stdint.h>
#endif
于 2008-09-24T13:37:10.213 回答
47

更新:Visual Studio 2010Visual C++ 2010 Express都有stdint.h. 它可以在C:\Program Files\Microsoft Visual Studio 10.0\VC\include

于 2010-04-13T08:26:21.023 回答
25

Visual Studio 2003 - 2008 (Visual C++ 7.1 - 9) 不声称与 C99 兼容。(感谢 rdentato 的评论。)

于 2008-09-24T11:53:21.417 回答
11

Boost 包含 cstdint.hpp 头文件,其中包含您正在寻找的类型:http: //www.boost.org/doc/libs/1_36_0/boost/cstdint.hpp

于 2008-09-24T13:56:48.343 回答
6

微软不支持 C99,也没有宣布任何计划。我相信他们打算跟踪 C++ 标准,但认为 C 实际上已经过时,除了作为 C++ 的子集。

Visual Studio 2003 及更高版本中的新项目默认设置了“编译为 C++ 代码 (/TP)”选项,因此任何 .c 文件都将编译为 C++。

于 2008-09-24T16:04:11.233 回答
4

另一种便携式解决方案:

POSH:便携式开源线束

“POSH 是一种简单、可移植、易于使用、易于集成、灵活、开源的‘线束’,旨在使编写跨平台库和应用程序的创建和移植过程显着减少繁琐。”

http://poshlib.hookatooka.com/poshlib/trac.cgi

正如书中描述和使用的那样:编写可移植代码:为多平台开发软件的介绍 作者:Brian Hook http://books.google.ca/books?id=4VOKcEAPPO0C

-杰森

于 2009-05-25T21:51:50.017 回答