I've recently got the source-code on a application. When im trying to build the solution, I get an error in all parts where winnt.h
is included. The error codes differs a bit, but they always point to these lines in winnt.h:
我最近得到了一个应用程序的源代码。当我尝试构建解决方案时,我在所有winnt的部分都有一个错误。h是包括在内。错误代码略有不同,但它们总是指向winnt.h中的这些行。
typedef void *PVOID;
typedef void * POINTER_64 PVOID64;
and
和
struct {
DWORD crc;
BYTE rgbReserved[14];
} CRC;
So, what could be the cause of this? winnt.h is a standard header and has not been modified. Does it has something to do with me using VS 2010, or me using 64-bit windows? or is it some sort of configuration which is needed?
那么,原因是什么呢?winnt。h是一个标准的标头,没有被修改。它和我使用VS 2010有什么关系,还是我使用64位windows?或者是某种需要的配置?
EDIT: Here's the exact error-codes:
编辑:这是准确的错误代码:
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(290): error C2146: syntax error : missing ';' before identifier 'PVOID64'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(290): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(8992): error C2146: syntax error : missing ';' before identifier 'Buffer'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(8992): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(8992): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(11525): error C2059: syntax error : 'constant'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(11525): error C2238: unexpected token(s) preceding ';'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(11556): error C2059: syntax error : 'constant'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(11556): error C2238: unexpected token(s) preceding ';'
6 个解决方案
#1
10
You need to include windows.h
rather than winnt.h
. When you include windows.h
it will, in turn, include winnt.h
. You need to do it this way for the necessary macros to be in place that are needed to compile winnt.h
.
您需要包括windows。而不是winnt.h h。当你有窗户。它将依次包括winnt.h。您需要这样做,以便必要的宏能够在需要编译winnt.h的地方。
In this case, POINTER_64
is defined in BaseTsd.h
like this:
在本例中,POINTER_64在BaseTsd中定义。h是这样的:
#define POINTER_64 __ptr64
But if you include winnt.h
before including windows.h
then POINTER_64
is not defined.
但如果你包括winnt。包括windows前h。然后POINTER_64没有定义。
#2
7
If you are using DirectX SDK, try changing the VC++ Directories for include and lib to be searched last.
如果您使用的是DirectX SDK,请尝试更改包含的vc++目录,并在最后搜索lib。
#3
2
It looks like your configuration of the Windows SDK is invalid. This error is caused by the fact that the compiler is unable to recognize the 'POINTER_64' statement. You may workaround this problem by replacing 'POINTER_64' with '__ptr64'.
看起来您的Windows SDK配置是无效的。这个错误是由编译器无法识别“POINTER_64”语句造成的。您可以用“__ptr64”替换“POINTER_64”来解决这个问题。
I had the same issue recently. Then I've reinstalled the latest version of the Windows SDK and this fixed the problem.
我最近遇到了同样的问题。然后我重新安装了Windows SDK的最新版本,这解决了问题。
UPDATE @David Heffernan, correctly points to the fact that one should include windows.h instead of winnt.h
更新@David Heffernan,正确地指出一个应该包括windows的事实。h代替winnt.h
#4
2
Try to remove DirectX SDK if you have one.
如果有的话,尝试删除DirectX SDK。
Here bug is accepted: http://connect.microsoft.com/VisualStudio/feedback/details/508204/vc10-0-errors-while-compiling-winnt-h
这里的bug被接受了:http://connect.microsoft.com/visualstudio/feedback/details/508204/vc10 -0-error -whil -编译-winnt-h。
#5
1
Corrected manually syntax in winnt.h :
修正了winnt中的手动语法。h:
typedef void * POINTER_64 PVOID64; => typedef void * POINTER_64, * PVOID64;
#6
0
If you are using librdkafka, you will get this error whenever "Windows.h" included.
如果您使用的是librdkafka,您将在“Windows”时得到这个错误。包括h”。
I fixed it by rename "librdkafka/include/basetsd.h" to a different name, or access this library header via sub path!
我将其命名为“librdkafka/include/basetsd”。“以不同的名称,或者通过子路径访问这个库头!”
I think the author of this library made this file to deal with OS platform compatibility. But with the same file name "basetsd.h" as Windows Core, it just confusing Visual Studio.
我认为这个库的作者制作了这个文件来处理操作系统平台的兼容性。但是使用相同的文件名“basetsd”。作为Windows的核心,它只是令人困惑的Visual Studio。
#1
10
You need to include windows.h
rather than winnt.h
. When you include windows.h
it will, in turn, include winnt.h
. You need to do it this way for the necessary macros to be in place that are needed to compile winnt.h
.
您需要包括windows。而不是winnt.h h。当你有窗户。它将依次包括winnt.h。您需要这样做,以便必要的宏能够在需要编译winnt.h的地方。
In this case, POINTER_64
is defined in BaseTsd.h
like this:
在本例中,POINTER_64在BaseTsd中定义。h是这样的:
#define POINTER_64 __ptr64
But if you include winnt.h
before including windows.h
then POINTER_64
is not defined.
但如果你包括winnt。包括windows前h。然后POINTER_64没有定义。
#2
7
If you are using DirectX SDK, try changing the VC++ Directories for include and lib to be searched last.
如果您使用的是DirectX SDK,请尝试更改包含的vc++目录,并在最后搜索lib。
#3
2
It looks like your configuration of the Windows SDK is invalid. This error is caused by the fact that the compiler is unable to recognize the 'POINTER_64' statement. You may workaround this problem by replacing 'POINTER_64' with '__ptr64'.
看起来您的Windows SDK配置是无效的。这个错误是由编译器无法识别“POINTER_64”语句造成的。您可以用“__ptr64”替换“POINTER_64”来解决这个问题。
I had the same issue recently. Then I've reinstalled the latest version of the Windows SDK and this fixed the problem.
我最近遇到了同样的问题。然后我重新安装了Windows SDK的最新版本,这解决了问题。
UPDATE @David Heffernan, correctly points to the fact that one should include windows.h instead of winnt.h
更新@David Heffernan,正确地指出一个应该包括windows的事实。h代替winnt.h
#4
2
Try to remove DirectX SDK if you have one.
如果有的话,尝试删除DirectX SDK。
Here bug is accepted: http://connect.microsoft.com/VisualStudio/feedback/details/508204/vc10-0-errors-while-compiling-winnt-h
这里的bug被接受了:http://connect.microsoft.com/visualstudio/feedback/details/508204/vc10 -0-error -whil -编译-winnt-h。
#5
1
Corrected manually syntax in winnt.h :
修正了winnt中的手动语法。h:
typedef void * POINTER_64 PVOID64; => typedef void * POINTER_64, * PVOID64;
#6
0
If you are using librdkafka, you will get this error whenever "Windows.h" included.
如果您使用的是librdkafka,您将在“Windows”时得到这个错误。包括h”。
I fixed it by rename "librdkafka/include/basetsd.h" to a different name, or access this library header via sub path!
我将其命名为“librdkafka/include/basetsd”。“以不同的名称,或者通过子路径访问这个库头!”
I think the author of this library made this file to deal with OS platform compatibility. But with the same file name "basetsd.h" as Windows Core, it just confusing Visual Studio.
我认为这个库的作者制作了这个文件来处理操作系统平台的兼容性。但是使用相同的文件名“basetsd”。作为Windows的核心,它只是令人困惑的Visual Studio。