简体   繁体   English

创建新的 c++ 控制台应用程序后出错

[英]Error after created new c++ console application

When I create new c++ console application (with MFC checkbox checked) in VS2010 I have a lot of errors during compilation connected with prsht.h , zmouse.h , commctrl.h .当我在 VS2010 中创建新的 c++ 控制台应用程序(选中 MFC 复选框)时,我在与prsht.hzmouse.hcommctrl.h相关的编译过程中遇到了很多错误。

I did not change anything in this file so I have not idea what is wrong.没有更改此文件中的任何内容,所以我不知道出了什么问题。 What are this files and how I can compile program without errors?这些文件是什么?我如何才能无误地编译程序?

Few of the many errors (113)许多错误中的少数 (113)

Error 13 error C1903: unable to recover from previous error(s);错误 13 错误 C1903:无法从以前的错误中恢复; stopping compilation c:\program files (x86)\microsoft sdks\windows\v7.0a\include\prsht.h 97 1 qwert停止编译 c:\program files (x86)\microsoft sdks\windows\v7.0a\include\prsht.h 97 1 qwert

Error 10 error C2065: 'CALLBACK': undeclared identifier 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: expected a ';' 19 IntelliSense:应为“;” c:\program files (x86)\microsoft sdks\windows\v7.0a\include\commctrl.h 165 21 c:\程序文件 (x86)\microsoft sdks\windows\v7.0a\include\commctrl.h 165 21

Error 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错误 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

You can try including the below in stdafx.h file before the #include "targetver.h" statement 您可以尝试在#include“ targetver.h”语句之前在stdafx.h文件中包含以下内容

#include "Winsock2.h"
#include "Windows.h"

#include "targetver.h"

These errors happened, because compiler treats symbols CALLBACK , HWND , etc. as new, it does not know them. 发生这些错误是因为编译器将符号CALLBACKHWND等视为新符号,它不知道它们。 These symbols are defined in windows.h header file. 这些符号在windows.h头文件中定义。 So the diagnosis is: windows.h was not included . 所以诊断是: windows.h was not included This can happen because of ruined SDK files, so you need to reinstall your SDK. 由于SDK文件损坏,可能会发生这种情况,因此您需要重新安装SDK。

On my computer the header files are included in the following chain: stdafx.h - afxwin.h - afx.h - afxver_.h - afxv_w32.h - windows.h , zmouse.h , commctrl.h 在我的计算机上,头文件包含在以下链中: stdafx.h - afxwin.h - afx.h - afxver_.h - afxv_w32.h - windows.hzmouse.hcommctrl.h

You can not include windows.h explicitly (as it was suggested before), because afxv_w32.h file has the following lines at the beginning: 您不能明确包含windows.h (如之前建议的那样),因为afxv_w32.h文件的开头有以下几行:

#ifdef _WINDOWS_
    #error WINDOWS.H already included.  MFC apps must not #include <windows.h>
#endif

You can take a look at this: http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/fff0ebaa-5153-40b9-89cf-cb9661abb2a4/ 您可以看一下: http : //social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/fff0ebaa-5153-40b9-89cf-cb9661abb2a4/

You may not cancelled the define code generated by VS:你可能没有取消VS生成的定义代码:
(in framework.h) (在 framework.h 中)

#pragma once

#include "targetver.h"
#define WIN32_LEAN_AND_MEAN

This define command told complier not include some specific headers like Windows. You may forgot to check the MFC support when creating the project.这个定义命令告诉编译器不要包含一些特定的头文件,比如 Windows。你可能在创建项目时忘记检查 MFC 支持。

After comment the #define, it may help.评论#define 后,它可能会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM