[英]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.