VC++ 10 抱怨很多类型没有定义,C99

发布于 2024-09-29 15:04:19 字数 308 浏览 0 评论 0原文

我正在尝试编译一个我下载的开源项目,该项目显然是用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我做我的改变 2024-10-06 15:04:19

Visual C++ 编译器不支持大多数 C99 功能。

如果您想使用标准的固定宽度整数类型,则需要确保包含 并使用 std:: 限定它们或包含

标准的固定宽度无符号类型名称为 uint32_tuint16_tuint8_t(即没有 _ > 在 uint 之间)。当然,如果您愿意,您可以 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 with std:: or include <stdint.h>.

The standard fixed-width unsigned type names are uint32_t, uint16_t, and uint8_t (that is, there is no _ between the u and int). 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).

清风挽心 2024-10-06 15:04:19

在 Visual Studio 中为自己定义这些类型非常容易,因为它们提供 __int(bitsize) 功能。

typedef __int64 int64_t;
typedef unsigned __int32 u_int32_t;
typedef unsigned __int16 u_int16_t;
typedef unsigned __int8 u_int8_t;

It's pretty easy to define these types for yourself in Visual Studio, since they offer __int(bitsize) functionality.

typedef __int64 int64_t;
typedef unsigned __int32 u_int32_t;
typedef unsigned __int16 u_int16_t;
typedef unsigned __int8 u_int8_t;
白芷 2024-10-06 15:04:19

您需要安装兼容的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文