#include <afx.h>

本文介绍了解决MFC应用程序编译时出现的fatal error C1189错误的方法。该错误通常由不正确的编译选项或头文件包含引起。文章详细解释了afx.h的作用及其包含的内容。

最近下载了一个程序,但是程序运行的时候出现了如下错误:

 fatal error C1189: #error :  Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]

最后发现头文件中多了#include <afx.h>。

经查询,网上对其解释如下:

一些定义与设置,为MFC提供最基本支持,将各种松散的东西组织起来,同时为MFC 类库的后续建立 提供方便。一个最简单的 MFC 只需 afxwin.h 即可,而afxwin.h 开始就是 #include <afx.h>

具体来说, afx.h 内容如下:
1. 编译选项设置,还包括warning等的预设值
2. 一些头文件:afxver_.h, C相关头文件,一些Win32库, 包库MFC库
3. 一些基本类声明,包括CArchieve, CArchieveException, CDumpContext, CException, CFile, CFileException, CFileFind, CMemFile,   CMemoryException , CNotSupportedException, CObject, CStdioFile
4 一些基本类型, 常量, 全局变量,函数,以及一些方便比较,转换的东东, 诊断函数支持, 还包括一些方便诊断的宏(由于MFC的严谨性, afx.h 中提供了大量方便其他MFC 头文件 的宏等)
参考资料:
http://zhidao.baidu.com/question/90547753.html
http://hi.baidu.com/showland/item/05aa70d8147548e6b3f777c3

 

// stdafx.h : 标准系统包含文件的包含文件, // 或是经常使用但不常更改的 // 特定于项目的包含文件 #pragma once #ifndef VC_EXTRALEAN #define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料 #endif #include "targetver.h" #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的 // 关闭 MFC 对某些常见但经常可放心忽略的警告消息的隐藏 #define _AFX_ALL_WARNINGS #include <afxwin.h> // MFC 核心组件和标准组件 #include <afxext.h> // MFC 扩展 #include <afxdisp.h> // MFC 自动化类 #ifndef _AFX_NO_OLE_SUPPORT #include <afxdtctl.h> // MFC 对 Internet Explorer 4 公共控件的支持 #endif #ifndef _AFX_NO_AFXCMN_SUPPORT #include <afxcmn.h> // MFC 对 Windows 公共控件的支持 #endif // _AFX_NO_AFXCMN_SUPPORT #include <afxcontrolbars.h> // 功能区和控件条的 MFC 支持 #ifdef _UNICODE #if defined _M_IX86 #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") #elif defined _M_X64 #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") #else #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") #endif #endif 代码解析
最新发布
11-28
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值