C99 stdint.h标头和MS Visual Studio
令我惊讶的是,我刚刚发现MS Visual Studio 2003向上版本中缺少C99 stdint.h。我确定它们是有原因的,但是有人知道我可以在哪里下载副本吗?没有此标头,我将无法定义有用的类型,例如uint32_t等。
解决方案
原来我们可以从以下位置下载此标头的MS版本:
https://github.com/mattn/gntp-send/blob/master/include/msinttypes/stdint.h
可以在这里找到一个便携式的:
http://www.azillionmonkeys.com/qed/pstdint.h
感谢Software Ramblings博客。
Visual Studio 2003 2008(Visual C ++ 7.1 9)不声称与C99兼容。 (感谢rdentato的评论。)
只需自己定义即可。
#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
Boost包含具有我们要查找的类型的cstdint.hpp头文件:http://www.boost.org/doc/libs/1_36_0/boost/cstdint.hpp
微软不支持C99,也没有宣布任何计划。我相信他们打算跟踪C ++标准,但认为C作为除C ++的子集外实际上已经过时了。
Visual Studio 2003和更高版本中的新项目默认情况下设置了"编译为C ++代码(/ TP)"选项,因此所有.c文件都将编译为C ++。
另一个便携式解决方案:
POSH:便携式开源工具
" POSH是一种简单,可移植,易于使用,易于集成,灵活,开放源代码的"工具",旨在使编写跨平台的库和应用程序的创建和移植工作大大减少。
http://poshlib.hookatooka.com/poshlib/trac.cgi
如书中所描述和使用的:
编写可移植的代码:为多种平台开发软件的简介
布莱恩·胡克(Brian Hook)
http://books.google.ca/books?id=4VOKcEAPPO0C
-杰森
更新:Visual Studio 2010和Visual C ++ 2010 Express都具有" stdint.h"。可以在" C:\ Program Files \ Microsoft Visual Studio 10.0 \ VC \ include"中找到