微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

'_WIN32_WINNT'/'WINVER':macros重新定义

我有一个VS2015 C++项目。 应用程序必须在Windows 7和XP上运行。 所以,我想将_WIN32_WINNT & WINVER设置为_WIN32_WINNT_WINXP 。

这是我的项目stdafx.h如何:

stdafx.h中

#pragma once #include "targetver.h" #define _WIN32_WINNT _WIN32_WINNT_WINXP #define WINVER _WIN32_WINNT_WINXP #include <WinSDKVer.h> // Windows Header Files: #include <windows.h>

编译时,我看到以下警告/错误

如何在Windows上的cuda推送调用中指定OpenMP执行策略?

自定义鼠标光标的阴影

在Windows上从另一个进程更改窗口上的鼠标光标

Android Studio找不到Visual Studio模拟器

Visual Studio从2005年升级到2015年,C ++ GUI保持XP主题不是系统主题

stdafx.h(12): error C2220: warning treated as error - no 'object' file generated 1>stdafx.h(12): warning C4005: '_WIN32_WINNT': macro redeFinition 1> C:Program Files (x86)Microsoft SDKsWindowsv7.1AincludeSDKDDKVer.h(197): note: see prevIoUs deFinition of '_WIN32_WINNT' 1>stdafx.h(13): warning C4005: 'WINVER': macro redeFinition 1> C:Program Files (x86)Microsoft SDKsWindowsv7.1AincludeSDKDDKVer.h(212): note: see prevIoUs deFinition of 'WINVER'

鼠标光标位图

在Windows上测量Opengl的运行时间?

在Linux上使用modal dialog时,显示繁忙游标的Swing渲染问题

C ++ – 在X窗口中更改光标

Visual Studio 2015将目标平台更改为Windows 7

因为#include "targetver.h"包含<sdkddkver.h> ,它们在编译环境尚未定义时已经定义了常量_WIN32_WINNT和WINVER。

事实上,自动生成的targetver.h告诉你如何解决这个问题:

#pragma once // Including SDKDDKVer.h defines the highest available Windows platform. // If you wish to build your application for a prevIoUs Windows platform,include WinSDKVer.h and // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. #include <SDKDDKVer.h>

解决方案简单 只需在包含targetver.h之前定义这些常量targetver.h 。 您可能必须使用XP的实际文字值,因为您没有包含定义的头文件

喜欢这个:

// x501 is XP #define _WIN32_WINNT 0x0501 #define WINVER 0x0501 #include "targetver.h" #include <windows.h>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐