我自己的mfc的demo要转换编译环境出现以下编译错误:

VS2010编译错误:fatal error C1189: #error : This file requires _WIN32_WINNT to be #defined at least to 0x0403...的解决方法

在google中找到解决办法,

_WIN32_WINNT这个宏对应定义的系统的版本号,如果太低的话,编译器就会认为代码无法在当前的系统上编译。

说了原因,下面是修改方法,就是在stdafx.h文件中修改相关的定义,修改完后的效果应该如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0501 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif
 
#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif
 
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0501 // Change this to the appropriate value to target Windows Me or later.
#endif
 
#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0601 // Change this to the appropriate value to target IE 5.0 or later.
#endif

但编译后又出现以下问题:

1> stdafx.cpp
1>d:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxwin.h(4024): error C2061: 语法错误: 标识符“PSCROLLBARINFO”
1>d:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxwin4.inl(184): error C2065: “PSCROLLBARINFO”: 未声明的标识符
1>d:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxwin4.inl(184): error C2146: 语法错误: 缺少“)”(在标识符“pScrollInfo”的前面)
1>d:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxwin4.inl(184): error C2761: “BOOL CScrollBar::GetScrollBarInfo(void) const”: 不允许成员函数重新声明
1>d:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxwin4.inl(184): error C2059: 语法错误:“)”
1>d:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxwin4.inl(185): error C2143: 语法错误 : 缺少“;”(在“{”的前面)
1>d:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxwin4.inl(185): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)

  比较郁闷。。。。

#ifndef WINVER				// 允许使用 Windows 95 和 Windows NT 4 或更高版本的特定功能。
//#define WINVER 0x0400 //为 Windows98 和 Windows 2000 及更新版本改变为适当的值。 刚刚此处没有修改
#define WINVER 0x0501
#endif

  现在应该正常。

参考网友:

http://www.cnblogs.com/madhenry/archive/2011/06/29/2093678.html

http://blog.csdn.net/cs_21cn/article/details/7925455

VS2003转VS2010 fatal error C1189: #error的更多相关文章

  1. fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>

    给对话框添加类, 报错 CalibrateMFCDlg.h(6) : error C2504: “CDialog”: 未定义基类 等多个错误 加上 #include "afxwin.h&qu ...

  2. 【转】fatal error C1189: #error : missing -D__STDC_CONSTANT_MACROS / #define __STDC_CONSTANT_MACROS

    转自:http://blog.csdn.net/friendan/article/details/46576699 fatal error C1189: #error :  missing -D__S ...

  3. fatal error C1189: #error : core.hpp header must be compiled as C++

    两次opencv工程需要设置为C++编译:找了一半天的解决方法. I am building a C application that uses OpenCV. when compiling, I g ...

  4. fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC

    出现如下错误: fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires ...

  5. fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC sha

    调试程序时出现以下问题:d:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afx.h(24): fatal e ...

  6. fatal error C1189: #error: "Oops: min() and/or max() are defined as preprocessor macros. Define NOMINMAX macro before including any system headers!"

    1.问题描述 vs2015 使用pg数据库的C++库文件4.0.1版本libpqxx.dll,包含头文件#include "pqxx\pqxx" 出现这个错误: fatal err ...

  7. error C2065: “CString”: 未声明的标识符 ;fatal error C1189: #error : afxstr.h can only be used in MFC proje

    转自VC错误:http://www.vcerror.com/?p=1388 问题描述: error C2065: "CString": 未声明的标识符 fatal error C1 ...

  8. fatal error C1189: #error : "No Target Architecture" 解决办法一

    在编译程序的时候发现报这个错误,在网上看到很多文章,说设置include路径,lib目录等等,都没有解决.最后调整了以下include文件的顺序,问题解决了.例如 从头文件a.h中截取的一段 type ...

  9. vc/atlmfc/include/afx.h(24) : fatal error C1189: #error : Building MFC application with /MD[d] (CRT

    环境:win7,64位,vs2012 1> c:/program files/microsoft visual studio 8/vc/atlmfc/include/afx.h(24) : fa ...

随机推荐

  1. 2015.4.2-SQL 简单语句(一)

    1.创建一个student表 create table student_masen( sno char(4) not null primarykey sname nchar(10) not null ...

  2. 解决ScrollView中嵌套ListView滚动效果冲突问题

    在ScrollView中嵌套使用ListView,ListView只会显示一行到两行的数据.起初我以为是样式的问题,一直在对XML文件的样 式进行尝试性设置,但始终得不到想要的效果.后来在网上查了查, ...

  3. 利用7z实现一键解压

    目的: 实现双击zip,7z,rar等文件时自动解压,解压完毕后自动打开文件夹. 工具: [本文末尾附有所有工具的下载地址] 7z.exe types 步骤: 新建"7z-自动解压" ...

  4. Hits per second 下降的几个原因

    1.首先看看服务器的资源消耗情况,可能是服务器 处理不了那么多请求, 有很多请求都在等待,此时可以监控一下服务器的资源 看看是不是有很多等待队列 是不是有很多的等待的请求,可用vmstat命令,第一个 ...

  5. information_schema.triggers 学习

    mysql实例中的每一个trigger 对应到information_schema.triggers 中有一行 1.information_schema.triggers 表的常用列: 1.trigg ...

  6. VCL线程的同步方法 Synchronize(用消息来同步)

    看本文时,可以同时参考:Delphi中线程类 TThread实现多线程编程(事件.临界区.Synchronize.WaitFor……) 先说一下RTL和VCL RTL(Run-Time library ...

  7. FNN模糊神经网络——信息系统客户服务感知评价

    案例描述 信息系统是否真正减轻业务人员的日常工作量提高工作效率?如何从提供“被动”服务转变为根据客户感知提供“主动”服务,真正实现电网企业对信息系统服务的有效管理?如何构建一套适合企业的信息系统客户服 ...

  8. Clone使用方法详解【转载】

    博客引用地址:Clone使用方法详解 Clone使用方法详解   java“指针”       Java语言的一个优点就是取消了指针的概念,但也导致了许多程序员在编程中常常忽略了对象与引用的区别,本文 ...

  9. 性能优化之Hibernate缓存讲解、应用和调优

    JavaMelody——一款性能监控.调优工具, 通过它让我觉得项目优化是看得见摸得着的,优化有了针对性.而无论是对于分布式,还是非分布,缓存是提示性能的有效工具. 数据层是EJB3.0实现的,而EJ ...

  10. What should we do when meet a crash in android?

    制造一个crash   为了演示的目的,我在libsensors的open_sensors_device中故意制造了一个crash:   static int open_sensors_device( ...