VC++ 10 抱怨很多类型没有定义,C99
我正在尝试编译一个我下载的开源项目,该项目显然是用 VC++ 7.1 编写的。
经过很多麻烦,作为 C++ 的新手,我设法下载并修复了项目使用的 STLPort 的包含内容。但是,我收到大约 15,000 个错误,抱怨某些类型未定义。其中一些是:
u_int32_t
int64_t
u_int16_t
u_int8_t
经过一番谷歌搜索后,我发现它们是在 C99 中添加的。在我之前的其他开发人员已经设法使用 VC 编译它。不过我正在使用 VC 10。
这个项目已经死了几年了,所以我无法联系到作者。
I'm trying to compile an open source project I downloaded which was apparently written in VC++ 7.1.
After a lot of trouble, being a novice at C++, I managed to download and fix includes for STLPort that the project uses. However, I get something like 15,000 errors complaining that certain types are not defined. A few of them are:
u_int32_t
int64_t
u_int16_t
u_int8_t
After a bit of Googling, I figured out they are added in C99. Other developers before me have managed to compile it using VC. I'm using VC 10 though.
The project has been dead for a few years, so I cannot contact the author.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Visual C++ 编译器不支持大多数 C99 功能。
如果您想使用标准的固定宽度整数类型,则需要确保包含
并使用std::
限定它们或包含
。标准的固定宽度无符号类型名称为
uint32_t
、uint16_t
和uint8_t
(即没有_
> 在u
和int
之间)。当然,如果您愿意,您可以 typedef 自己的类型(虽然您应该对新代码使用标准 typedef,但您可能需要 typedef 自己的类型才能与遗留代码进行互操作)。The Visual C++ compiler does not support most C99 features.
If you want to use the standard fixed-width integer types, you need to make sure you include
<cstdint>
and qualify them withstd::
or include<stdint.h>
.The standard fixed-width unsigned type names are
uint32_t
,uint16_t
, anduint8_t
(that is, there is no_
between theu
andint
). You can, of course, typedef your own types if you want to (while you should use the standard typedefs for new code, you may need to typedef your own to interoperate with legacy code).在 Visual Studio 中为自己定义这些类型非常容易,因为它们提供 __int(bitsize) 功能。
It's pretty easy to define these types for yourself in Visual Studio, since they offer __int(bitsize) functionality.
您需要安装兼容的 C99 编译器和库,并指向 VC++10 环境。
但是我怀疑找到构建/制作文件并使用它们的更简单的方法。
You need to install a compatible C99 compiler and libraries, and the point the VC++10 environment at those.
However I suspect the easier way to find the build/make files and use those.