C++ 'uint32_t' 标识符未找到错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5162784/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 17:34:07  来源:igfitidea点击:

'uint32_t' identifier not found error

c++cvisual-c++

提问by kevin

I'm porting code from Linux C to Visual C++ for windows.

我正在将代码从 Linux C 移植到 Windows 的 Visual C++。

Visual C++ doesn't know #include <stdint.h>so I commented it out.

Visual C++ 不知道#include <stdint.h>所以我把它注释掉了。

Later, I found a lot of those 'uint32_t': identifier not founderrors. How can it be solved?

后来,我发现了很多这样的'uint32_t': identifier not found错误。如何解决?

回答by templatetypedef

This type is defined in the C header <stdint.h>which is part of the C++11 standard but not standard in C++03. According to the Wikipedia page on the header, it hasn't shipped with Visual Studio until VS2010.

这种类型是在 C 头文件中定义的,<stdint.h>它是 C++11 标准的一部分,但不是 C++03 的标准。根据标题上的维基百科页面,它直到 VS2010 才随 Visual Studio 一起提供。

In the meantime, you could probably fake up your own version of the header by adding typedefs that map Microsoft's custom integer typesto the types expected by C. For example:

同时,您可以通过添加typedefMicrosoft 的自定义整数类型映射到 C 期望的类型的s 来伪造您自己的标头版本。例如:

typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
/* ... etc. ... */

Hope this helps!

希望这可以帮助!

回答by Tigerle

You can #include <cstdint>. It's part of C++-standard since 2011.

你可以#include <cstdint>。自 2011 年以来,它是 C++ 标准的一部分。

回答by Nacho Barreto

I have the same error and it fixed it including in the file the following

我有同样的错误,它修复了它,包括在文件中

#include <stdint.h>

at the beginning of your file.

在文件的开头。

回答by ildjarn

Boost.Configoffers these typedefs for toolsets that do not provide them natively. The documentation for this specific functionality is here: Standard Integer Types

提升Config为本身不提供它们的工具集提供这些 typedef。此特定功能的文档在这里:标准整数类型

回答by Brandon Leiran

There is an implementation available at the msinttypes project page- "This project fills the absence of stdint.h and inttypes.h in Microsoft Visual Studio".

msinttypes 项目页面上有一个可用的实现——“这个项目填补了 Microsoft Visual Studio 中 stdint.h 和 inttypes.h 的缺失”。

I don't have experience with this implementation, but I've seen it recommended by others on SO.

我没有这种实现的经验,但我已经看到其他人在 SO 上推荐了它。

回答by ST3

On Windows I usually use windows types. To use it you have to include <Windows.h>.

在 Windows 上,我通常使用 Windows 类型。要使用它,您必须包含<Windows.h>.

In this case uint32_t is UINT32 or just UINT.

在这种情况下 uint32_t 是 UINT32 或只是 UINT。

All types definitions are here: http://msdn.microsoft.com/en-us/library/windows/desktop/aa383751%28v=vs.85%29.aspx

所有类型定义都在这里:http: //msdn.microsoft.com/en-us/library/windows/desktop/aa383751%28v=vs.85%29.aspx

回答by Darqer

I had to run project in VS2010 and I could not introduce any modifications in the code. My solution was to install vS2013 and in VS2010 point VC++ Directories->IncludeDirectories to Program Files(x86)\Microsoft Visual Studio 12.0\VC\include. Then my project compiled without any issues.

我不得不在 VS2010 中运行项目,我无法在代码中引入任何修改。我的解决方案是安装 vS2013 并在 VS2010 中点 VC++ Directory->IncludeDirectories to Program Files(x86)\Microsoft Visual Studio 12.0\VC\include。然后我的项目编译没有任何问题。