C99 stdint.h头文件和MS Visual Studio
-
02-07-2019 - |
题
令我惊讶的是,我刚刚发现MS Visual Studio 2003向上缺少C99 stdint.h。我确定他们有他们的理由,但有谁知道我可以在哪里下载副本?如果没有这个标题,我就没有对uint32_t等有用类型的定义。
解决方案
事实证明,您可以从以下网址下载此标头的MS版本:
https://github.com/mattn/ gntp-SEND /斑点/主/包含/ msinttypes / stdint.h
便携式可以在这里找到:
http://www.azillionmonkeys.com/qed/pstdint.h
感谢软件漫游博客。
其他提示
自己定义一下。
#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
更新: Visual Studio 2010 和 Visual C ++ 2010 Express 都有 stdint.h
。它可以在 C:\ Program Files \ Microsoft Visual Studio 10.0 \ VC \ include
Visual Studio 2003 - 2008(Visual C ++ 7.1 - 9)并不声称与C99兼容。 (感谢rdentato的评论。)
Boost包含cstdint.hpp头文件,其中包含您要查找的类型: http://www.boost.org/doc/libs/1_36_0/boost/cstdint.hpp
微软不支持C99,也没有宣布任何计划。我相信他们打算跟踪C ++标准,但认为C有效地过时了,除非作为C ++的一个子集。
Visual Studio 2003及更高版本中的新项目具有“Compile as C ++ Code(/ TP)”。默认情况下设置选项,因此任何.c文件都将编译为C ++。
另一种便携式解决方案:
POSH:便携式开源线束
http://poshlib.hookatooka.com/poshlib/trac.cgi
如书中所述和使用的: 编写可移植代码:介绍为多个平台开发软件 布莱恩胡克 http://books.google.ca/books?id=4VOKcEAPPO0C
-Jason