首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VC >

关于"afx.h"头文件,该如何处理

2012-12-17 
关于afx.h头文件我用vc2008新建了一个窗体项目,只写了一句话:#include afx.h 运行出错:fatal error C1

关于"afx.h"头文件
我用vc2008新建了一个窗体项目,只写了一句话:#include "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]

在项目属性——配置属性 ——常规——MFC的使用——选择“在静态库中使用 MFC” 提示错误: 
1>------ 已启动生成: 项目: JLU_DRGS, 配置: Debug Win32 ------ 
1>正在编译... 
1>cl: 命令行error D8016 :“/MTd”和“/clr:pure”命令行选项不兼容 
1>项目: error PRJ0002 : 错误的结果2 (从“F:\Microsoft Visual Studio 9.0\VC\bin\cl.exe”返回)。 
1>生成日志保存在“file://f:\JLU_DRGS\VC\JLU_DRGS\JLU_DRGS\Debug\BuildLog.htm” 
1>JLU_DRGS - 1 个错误,个警告 
========== 生成: 成功0 个,失败1 个,最新0 个,跳过0 个========== 

在项目属性——配置属性 ——常规——MFC的使用——选择“在共享 DLL 中使用 MFC” 提示错误: 
1>------ 已启动生成: 项目: JLU_DRGS, 配置: Debug Win32 ------ 
1>正在编译... 
1>stdafx.cpp 
1> WINVER not defined. Defaulting to 0x0600 (Windows Vista) 
1>F:\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxv_w32.h(247) : error C3641: “DrawState”: 用 /clr:pure 或 /clr:safe 编译的函数的调用约定“__stdcall ”无效 
1>F:\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxv_w32.h(265) : error C3641: “DrawStatusText”: 用 /clr:pure 或 /clr:safe 编译的函数的调用约定“__stdcall ”无效 
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winbase.h(2534) : error C3641: “FreeResource”: 用 /clr:pure 或 /clr:safe 编译的函数的调用约定“__stdcall ”无效 
1>F:\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxv_w32.h(279) : error C3641: “UnlockResource”: 用 /clr:pure 或 /clr:safe 编译的函数的调用约定“__stdcall ”无效 
1>F:\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlconv.h(90) : error C3641: “InterlockedExchangePointer”: 用 /clr:pure 或 /clr:safe 编译的函数的调用约定“__stdcall ”无效 
1>F:\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlconv.h(102) : error C3641: “ATL::_AtlGetConversionACP”: 用 /clr:pure 或 /clr:safe 编译的函数的调用约定“__stdcall ”无效 
1>F:\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlconv.h(535) : error C3641: “AtlA2WHelper”: 用 /clr:pure 或 /clr:safe 编译的函数的调用约定“__stdcall ”无效 
1>F:\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlconv.h(554) : error C3641: “AtlW2AHelper”: 用 /clr:pure 或 /clr:safe 编译的函数的调用约定“__stdcall ”无效 
1>F:\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlconv.h(572) : error C3641: “AtlA2WHelper”: 用 /clr:pure 或 /clr:safe 编译的函数的调用约定“__stdcall ”无效 
1>F:\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlconv.h(577) : error C3641: “AtlW2AHelper”: 用 /clr:pure 或 /clr:safe 编译的函数的调用约定“__stdcall ”无效 
1>F:\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlconv.h(530) : error C3641: “AtlDevModeW2A”: 用 /clr:pure 或 /clr:safe 编译的函数的调用约定“__stdcall ”无效 
1>F:\Microsoft Visual Studio 9.0\VC\atlmfc\include\atltrace.h(65) : error C2440: “default argument”: 无法从“int (__cdecl *)(int,const char *,int,const char *,const char *,...)”转换为“ATL::CTrace::fnCrtDbgReport_t” 


1>        使用 /clr:pure 和 /clr:safe 时,函数地址服从 __clrcall 调用约定;请考虑在目标类型中使用 __clrcall 
1>F:\Microsoft Visual Studio 9.0\VC\atlmfc\include\atltrace.h(146) : fatal error C1903: 无法从以前的错误中恢复;正在停止编译 
1>生成日志保存在“file://f:\JLU_DRGS\VC\JLU_DRGS\JLU_DRGS\Debug\BuildLog.htm” 
1>JLU_DRGS - 13 个错误,0 个警告 
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ========== 


继续帮助,不胜感激
[解决办法]
该回复于2009-06-18 17:26:10被版主删除
[解决办法]
很简单,AFX.H是系统文件,你include的时候应该用<>。


#include <afx.h>

[解决办法]
参考
http://blog.csdn.net/charleyf/archive/2009/05/13/4180213.aspx
[解决办法]
#include <afx.h>   和#include "afx.h"两种写法都出错,问题不在于此
[解决办法]
在项目属性——配置属性 ——常规——MFC的使用——选择“在共享 DLL 中使用 MFC

至于这种解决方案,试过了,错误列在上面
[解决办法]
关注
[解决办法]
呜呼哀哉!竟无人能解决此问题?
[解决办法]
高手哪里去了?急需帮助啊
[解决办法]
1>cl: 命令行error D8016 :“/MTd”和“/clr:pure”命令行选项不兼容 
编译选项用clr不要用clr:pure 
[解决办法]
按照楼上的方法试了,编译通过,运行时弹出一个对话框:
 Debug Assertion  Failed!
 Program:...\Visual studio2088\Projects\filesearch\Debug\filesearch.exe
 File:f:\dd\vctools\crt_bld\self_x86\crt\src\dgb.heap.c
 Line:1511
 
 Expression:_CrtIsValidHeapPointer(0UserData)
 后面的错误信息就不贴出来了
[解决办法]
引用:
按照楼上的方法试了,编译通过,运行时弹出一个对话框:
Debug Assertion? Failed!
Program:...\Visual studio2088\Projects\filesearch\Debug\filesearch.exe
File:f:\dd\vctools\crt_bld\self_x86\crt\src\dgb.heap.c
Line:1511

Expression:_CrtIsValidHeapPointer(0UserData)
后面的错误信息就不贴出来了

你的代码有问题

[解决办法]
我新建的windows窗体项目,只写一句代码::#include "afx.h"  
[解决办法]
该回复于2009-06-04 11:52:37被版主删除
[解决办法]
#include "afx.h"改成#include "stdafx.h"
[解决办法]
写出程序

VC++2008:

打开工程后,点击“工程”-右击-“属性”,在打开的对话框中切换到“配置属性"选项卡,将其中的“MFC的使用"设置为"在共享DLL中使用MFC",确定即可
[解决办法]
在项目属性—“常规”里面,把“公共语言运行库支持”改一下试试,不用pure和safe。 
[解决办法]
楼主  解决了没啊?我现在也遇到了这个问题  没地着手啊

热点排行