VC++编译错误error C2065: “HANDLE”: 未声明的标识符及添加winbase.h后提示winbase.h(243): error C2146: 语法错误: 缺少“;”(在标识符“Internal”的前面)的解决办法

问题描述:

VC++程序编译时提示错误:error C2065: “HANDLE”: 未声明的标识符等众多错误提示,如下所示:

error C2065: “HANDLE”: 未声明的标识符
error C2146: 语法错误: 缺少“;”(在标识符“hFind”的前面)
error C2065: “hFind”: 未声明的标识符
error C2065: “INVALID_HANDLE_VALUE”: 未声明的标识符
error C2065: “WIN32_FIND_DATA”: 未声明的标识符
error C2146: 语法错误: 缺少“;”(在标识符“fdata”的前面)
error C2065: “fdata”: 未声明的标识符
error C2065: “hFind”: 未声明的标识符
error C2065: “fdata”: 未声明的标识符
error C3861: “FindFirstFile”: 找不到标识符
error C2065: “hFind”: 未声明的标识符
error C2065: “INVALID_HANDLE_VALUE”: 未声明的标识符
error C2065: “fdata”: 未声明的标识符
error C2228: “.cFileName”的左边必须有类/结构/联合

查找了一下所对应的头文件为winbase.h,自然就添加上去了:

#include <winbase.h>

但是当添加winbase.h后又提示winbase.h(243): error C2146: 语法错误: 缺少“;”(在标识符“Internal”的前面)等众多错误提示,如下所示:

1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(243): error C2146: 语法错误: 缺少“;”(在标识符“Internal”的前面)
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(243): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(243): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(244): error C2146: 语法错误: 缺少“;”(在标识符“InternalHigh”的前面)
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(244): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(244): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(247): error C2146: 语法错误: 缺少“;”(在标识符“Offset”的前面)
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(247): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(247): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(248): error C2146: 语法错误: 缺少“;”(在标识符“OffsetHigh”的前面)
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(248): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(248): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(250): error C2146: 语法错误: 缺少“;”(在标识符“Pointer”的前面)
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(250): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(250): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(253): error C2146: 语法错误: 缺少“;”(在标识符“hEvent”的前面)
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(253): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(253): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(257): error C2146: 语法错误: 缺少“;”(在标识符“lpCompletionKey”的前面)
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(257): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(257): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(259): error C2146: 语法错误: 缺少“;”(在标识符“Internal”的前面)
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(259): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(259): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(260): error C2146: 语法错误: 缺少“;”(在标识符“dwNumberOfBytesTransferred”的前面)
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(260): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(260): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(264): error C2146: 语法错误: 缺少“;”(在标识符“nLength”的前面)
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(264): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(264): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(265): error C2146: 语法错误: 缺少“;”(在标识符“lpSecurityDescriptor”的前面)
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winbase.h(265): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int

解决办法:

  将#include <winbase.h>替换成#include<windows.h>就行了。

#include<windows.h> 

原文地址:https://www.cnblogs.com/rainbow70626/p/9078254.html

时间: 2024-08-04 18:42:55

VC++编译错误error C2065: “HANDLE”: 未声明的标识符及添加winbase.h后提示winbase.h(243): error C2146: 语法错误: 缺少“;”(在标识符“Internal”的前面)的解决办法的相关文章

error C2065:未声明的标识符错误

原文地址:http://blog.sina.com.cn/s/blog_8216ada701017evx.html 在VS2010下进行VC++调试时,出现这样一种错误:error C2065:未声明的标识符,当时感觉十分怪异,为什么说怪异呢?因为如果在.cpp中未引入相关.h文件出现这样的错误很正常,但是现在是已经引入了相关的头文件,却还是出现了诸如error C2065.error C2087.error C2133...的错误. 情况是这样的,新建了一个工程项目,想使用其他工程中定义的同一

error C2065:未声明的标识符错误 解决方法

开发的时候遇到CComPtr<IDispatch> spDisp = GetHtmlDocument(); 这样的定义,添加了 #include <atlbase.h>#include <atlcom.h>#include <atlctl.h> 等头文件,还是编译出错,提示error C2065: “CComPtr”: 未声明的标识符 这是扎回事啊,其他项目中也有这样的定义啊,也都加了同样的头文件啊,为啥他们没问题呢.郁闷了半天. 后来对比发现少了using

error C2065: “GAA_FLAG_SKIP_ANYCAST”: 未声明的标识符

在编译文章: 使用GetAdaptersAddresses函数获取物理MAC地址中的代码时,出现以下错误: 错误 2 error C2065: "GAA_FLAG_SKIP_ANYCAST": 未声明的标识符 f:\ccprojects\获取网卡物理地址mac地址\获取网卡物理地址mac地址\temporary.cpp 11 1 获取网卡物理地址MAC地址 环境:Windows7+VS2010 解决办法: 添加头文件: #include<WinSock2.h> #inclu

error C2065: “CString”: 未声明的标识符

在编译文章: 使用GetAdaptersAddresses函数获取物理MAC地址中的代码时,出现以下错误: 错误 3 error C2065: "CString": 未声明的标识符 f:\ccprojects\获取网卡物理地址mac地址\获取网卡物理地址mac地址\temporary.h 13 1 获取网卡物理地址MAC地址 环境:Windows7+VS2010 解决办法: 添加头文件: #include <afx.h> 项目属性>配置属性>常规>MFC的

error C2065: “cout”: 未声明的标识符

error C2065: “cout”: 未声明的标识符 在头文件下加上: #include <iostream> using namespace std;

错误 1 error C2065: “IDC_LISTBOX”: 未声明的标识符

错误的可能原因及解决方法如下:1.出错文件中没有包含资源文件ID声明的resource.h文件.在出错文件中加入#include “resource.h”语句. 2.工程附件包含目录的路径下没有resource.h文件.修改路径即可. 3.工程所在文件夹下存在resource.h文件,但其中没有资源ID的定义,导致真正的resource.h没有包含进去,删除之.一个解决方案里面有多个工程,可能会把所有资源ID的声明放到一个文件中.在各个工程中实现对话框功能的文件中,只需包含该文件即可.但是,当新

error C2065: “M_PI”: 未声明的标识符

1.首先,程序中头文件的选择,要选择<math.h>头文件,在<cmath>文件中是没有对M_PI 的定义的(现在的<cmath>中对M_PI好像已有定义).2.选择:项目——>”XXX属性"——>配置属性——>C/C++——>预处理器——>预处理器定义,将“_USE_MATH_DEFINES”添加进去3.编译成功--------------------- 作者:囚魇 来源:CSDN 原文:https://blog.csdn.ne

找不到标识符、未声明的标识符

1.error C3861: "_T": 找不到标识符 #include <tchar.h> 2.error C3861: "time": 找不到标识符 查看代码,发现已经包含了 time.h 头文件,不应该报这个错误啊. 找了半天,发现项目文件中有一个叫 Time.h 的头文件,可能是和vs自带的time.h冲突了. 将该 Time.h 头文件改名为 MyTime.h 之后,再把原来引用 Time.h 的地方 替换成 MyTime.h 就好了. 3.&

error C2039: &#39;SetDefaultDllDirectories&#39;错误解决办法

使用VS2013+WDK8.1+Win7开发UMDF驱动,当使用了CComPtr类,包含了atlcomcli.h头文件却报错,错误如下: Error 3 error C2039: 'SetDefaultDllDirectories' : is not a member of '`global namespace'' 可是使用VS2012+WDK8.0+Win7却没有这个问题. 经过一番折腾终于找到了解决办法,在预定义中增加一项定义  _USING_V110_SDK71_ 具体见下图: error