C99 stdint.h头文件和MS Visual Studio

Rob*_*Rob 113 c c++ c99 visual-studio

令我惊讶的是,我刚刚发现MS Visual Studio 2003向上缺少C99 stdint.h.我确定他们有他们的理由,但有谁知道我可以在哪里下载副本?如果没有这个头文件,我就没有uint32_t等有用类型的定义.

Rob*_*Rob 82

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

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

便携式可以在这里找到:

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

感谢Software Rambling的博客.

  • 一个公共领域(不是麻省理工学院/ BSD许可证 - 你甚至不需要保留版权归属)stdint.h for MSVC(MinGW略有修改版本):http://snipplr.com/view/18199/ stdinth / (13认同)

Nic*_*uso 46

只需自己定义它们.

#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
Run Code Online (Sandbox Code Playgroud)

  • 我错过了什么或不应该是typedef unsigned __int64 uint64_t; ? (4认同)

Ash*_*ppa 44

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

  • 以及在`std ::`中喜欢它的C++用户的<cstdint>. (3认同)

Ada*_*itz 23

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


Nem*_*vic 11

Boost包含cstdint.hpp头文件以及您要查找的类型:http://www.boost.org/doc/libs/1_36_0/boost/cstdint.hpp

  • 目前尚不清楚 - 他在Visual Studio中询问C99标题,而没有指定他使用的是哪种语言.无论如何它不能是C99,因为微软不支持它. (4认同)

Mik*_*ick 5

微软不支持C99,也没有宣布任何计划.我相信他们打算跟踪C++标准,但认为C有效地过时,除非作为C++的一个子集.

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