语法错误:缺少';'编译winnt.h时在标识符"PVOID64"之前 [英] syntax error : missing ';' before identifier 'PVOID64' when compiling winnt.h

查看:97
本文介绍了语法错误:缺少';'编译winnt.h时在标识符"PVOID64"之前的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在应用程序上获得了源代码.当我尝试构建解决方案时,在包含 winnt.h 的所有部分都出现错误.错误代码有所不同,但是它们始终指向winnt.h中的这些行:

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:

typedef void *PVOID;
typedef void * POINTER_64 PVOID64;

struct {
    DWORD crc;
    BYTE  rgbReserved[14];
} CRC;

那么,这可能是什么原因?winnt.h是标准头文件,尚未修改.使用VS 2010或使用64位Windows与它有关吗?还是需要某种配置?

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?

这是确切的错误代码:

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 ';'

推荐答案

您需要包含 windows.h 而不是 winnt.h .当您包含 windows.h 时,它将依次包含 winnt.h .您需要通过这种方式来放置编译 winnt.h 所需的必要宏.

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.

在这种情况下,像这样在 BaseTsd.h 中定义 POINTER_64 :

In this case, POINTER_64 is defined in BaseTsd.h like this:

#define POINTER_64 __ptr64

但是,如果在包含 windows.h 之前包含 winnt.h ,则未定义 POINTER_64 .

But if you include winnt.h before including windows.h then POINTER_64 is not defined.

这篇关于语法错误:缺少';'编译winnt.h时在标识符"PVOID64"之前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆