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
'uint32_t' identifier not found error
提问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 found
errors. 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 typedef
s that map Microsoft's custom integer typesto the types expected by C. For example:
同时,您可以通过添加typedef
将Microsoft 的自定义整数类型映射到 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
回答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。然后我的项目编译没有任何问题。