error C2146: 语法错误: 缺少“;”(在标识符“WINAPI”的前面) 及 “error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int” 解决方案
来源:互联网 发布:热力地图js 编辑:程序博客网 时间:2024/06/08 15:40
在VS里字定义了一个工程,添加了一个CPP和H,编译时出现了以下奇怪的错误:
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\tlhelp32.h(30): error C2146: 语法错误: 缺少“;”(在标识符“WINAPI”的前面)
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\tlhelp32.h(30): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\tlhelp32.h(30): error C2146: 语法错误: 缺少“;”(在标识符“CreateToolhelp32Snapshot”的前面)
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\tlhelp32.h(30): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\tlhelp32.h(31): error C2065: “DWORD”: 未声明的标识符
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\tlhelp32.h(31): error C2146: 语法错误: 缺少“)”(在标识符“dwFlags”的前面)
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\tlhelp32.h(31): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\tlhelp32.h(33): error C2059: 语法错误:“)”
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\tlhelp32.h(64): error C2146: 语法错误: 缺少“;”(在标识符“dwSize”的前面)
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\tlhelp32.h(64): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
像这样的问题一般一般是由于头文件包含引起的错误。
在CPP的最前面包含 windows.h问题就解决了。为什么会想到这一点呢?同样的CPP和H,在另一个工程里可用,而在这里不能用。对比发现可用的那个工程里,该CPP包含了STDAFX.H,而STDAFX.H里包含了window.h。
话说windows.h 怎么就那么重要呢,不包含,还不让编译通过。打开windows.h,里面全部是头文件包含。VS已经帮我们定义好了在window平台上开发程序所需的头文件和顺序。
以后进行windows编程的时候记得包含就行了。
再来看下stdafx.h,包含可是很标准的哟
// stdafx.h : 标准系统包含文件的包含文件,// 或是经常使用但不常更改的// 特定于项目的包含文件//#pragma once#include "targetver.h"#include <stdio.h>#include <tchar.h>// TODO: 在此处引用程序需要的其他头文件#include <windows.h>
这个顺序要记住啦。。。
- error C2146: 语法错误: 缺少“;”(在标识符“WINAPI”的前面) 及 “error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int” 解决方案
- error C2146: 语法错误: 缺少“;”(在标识符“m_tTimer”的前面) error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- error C2144: 语法错误 : “void”的前面应有“;” error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int;
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认int 错误的解决方法
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int 错误的解决方法
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int"错误的解决方法
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- afxwin1.inl(1014) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- ”error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int“ 解决办法
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- 【MFC BUG】error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- vs2008编译遇到error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- 如何理解c和c++的复杂类型声明?
- dll动态链接库简单入门
- Reorder List
- Unity3D命令行Build
- display:table
- error C2146: 语法错误: 缺少“;”(在标识符“WINAPI”的前面) 及 “error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int” 解决方案
- 黑马程序员_Java多线程
- 关于*((volatile int*)0x0000xxxx)
- vs2013开发上位机软件和单片机通信
- hdu 1166 线段树之一
- 轻松玩转json与jQuery的交互
- C# Excel CSV DataTable DataSet 相关代码及资料整理
- Map遍历
- grunt整合版-30分钟学会打包前端代码