我在 VC++ 2010 中有一个 C++ 项目,我在没有预编译头文件的情况下启动它。它工作正常,但是当我向它添加 MFC 多线程时,它开始在 afxmt.h 中给出异常。当我在另一个带有预编译 header 的项目中测试包含 afxmt.h 时,它没有任何问题。
问题是,我如何让 MFC (afxmt.h) 在没有预编译头文件的项目上工作?或者我应该把它改成带有预编译头文件的吗?
编辑:
这些是异常(exception)情况:
First-chance exception at 0x789394ea (mfc100ud.dll) in Quick_Test.exe: 0xC0000005: Access violation reading location 0x00000000.
Unhandled exception at 0x77b015de in Quick_Test.exe: 0xC0000005: Access violation reading location 0x00000000.
这些发生在空项目中(没有预编译头文件)。 代码是:
#include "afxmt.h"
最佳答案
使用预编译头文件的项目自动插入#include afxmt.h;进入每个源文件的编译过程。如果您不使用预编译 header ,则需要将 #include 添加到每个执行需要该 header 的操作的源文件中。
关于c++ - 预编译头对mfc有多大影响?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12974338/