[英]Error after created new c++ console application
当我在 VS2010 中创建新的 c++ 控制台应用程序(选中 MFC 复选框)时,我在与prsht.h
、 zmouse.h
、 commctrl.h
相关的编译过程中遇到了很多错误。
我没有更改此文件中的任何内容,所以我不知道出了什么问题。 这些文件是什么?我如何才能无误地编译程序?
许多错误中的少数 (113)
错误 13 错误 C1903:无法从以前的错误中恢复; 停止编译 c:\program files (x86)\microsoft sdks\windows\v7.0a\include\prsht.h 97 1 qwert
错误 10 error C2065: 'CALLBACK': undeclared identifier c:\program files (x86)\microsoft sdks\windows\v7.0a\include\prsht.h 97 1 qwert
19 IntelliSense:应为“;” c:\程序文件 (x86)\microsoft sdks\windows\v7.0a\include\commctrl.h 165 21
错误 2 error C2433: 'HWND': 'inline' not permitted on data declarations c:\program files (x86)\microsoft sdks\windows\v7.0a\include\zmouse.h 141 1 qwert
您可以尝试在#include“ targetver.h”语句之前在stdafx.h文件中包含以下内容
#include "Winsock2.h"
#include "Windows.h"
#include "targetver.h"
发生这些错误是因为编译器将符号CALLBACK
, HWND
等视为新符号,它不知道它们。 这些符号在windows.h
头文件中定义。 所以诊断是: windows.h was not included
。 由于SDK文件损坏,可能会发生这种情况,因此您需要重新安装SDK。
在我的计算机上,头文件包含在以下链中: stdafx.h - afxwin.h - afx.h - afxver_.h - afxv_w32.h - windows.h
, zmouse.h
, commctrl.h
您不能明确包含windows.h
(如之前建议的那样),因为afxv_w32.h
文件的开头有以下几行:
#ifdef _WINDOWS_
#error WINDOWS.H already included. MFC apps must not #include <windows.h>
#endif
您可以看一下: http : //social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/fff0ebaa-5153-40b9-89cf-cb9661abb2a4/
你可能没有取消VS生成的定义代码:
(在 framework.h 中)
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN
这个定义命令告诉编译器不要包含一些特定的头文件,比如 Windows。你可能在创建项目时忘记检查 MFC 支持。
评论#define 后,它可能会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.