Compiler Errors in atlwin.h

拟墨画扇 提交于 2019-12-01 11:21:38

问题


When including atlwin.h from the Microsoft ATL libraries in Visual Studio 2013 building will result in numerous complier errors about undefined elements.

i.e.

#include <atlwin.h>
class MainWnd : public CWindowImpl<MainWnd>
{};

"CWindowImpl: base class is not defined" error.

or

HMONITOR is not defined

This does not occur when building using VS2010.

How can I fix that?


回答1:


The problem is with the targeted version of windows in the stdafx.h file

from MSDN

Visual C++ no longer supports targeting Windows 95, Windows 98, Windows ME, or Windows NT. If your WINVER or _WIN32_WINNT macros are assigned to one of these versions of Windows, you must modify the macros. When you upgrade a project that was created by using an earlier version of Visual C++, you may see compilation errors related to the WINVER or _WIN32_WINNT macros if they are assigned to a version of Windows that is no longer supported.

So, changing

#ifndef WINVER  
#define WINVER 0x0400   
#endif

to

#ifndef WINVER  
#define WINVER 0x0500
#define _WIN32_WINNT 0x0500
#endif

corrects the build problem




回答2:


CWindowImpl is defined in <atlwin.h>, so you need to include that. I don't know what the file atldwin.h that you're including is, but apparently it doesn't contain that class.

Edit: According to a comment below by CCondron, this is due to targeting versions of Windows no longer supported by Visual C++. To fix, add:

#define WINVER 0x0500 
#define _WIN32_WINNT 0x0500


来源:https://stackoverflow.com/questions/20314124/compiler-errors-in-atlwin-h

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!