简体   繁体   English

预编译头有多少影响mfc?

[英]How much precompiled headers affect mfc?

I have a C++ project in VC++ 2010 and I started it without precompiled headers. 我在VC ++ 2010中有一个C ++项目,我在没有预编译头的情况下启动它。 It was working fine, but when I added MFC multithreading to it, it started giving exceptions in afxmt.h. 它工作正常,但当我添加MFC多线程时,它开始在afxmt.h中提供异常。 When I tested including afxmt.h in an another project WITH precompiled headers, it worked without any problems. 当我在另一个带有预编译头文件的项目中测试包含afxmt.h时,它没有任何问题。

The question is, how would I get MFC (afxmt.h) working on the project that has no precompiled headers? 问题是,如何让MFC(afxmt.h)处理没有预编译头的项目? Or should I just change it into one with precompiled headers? 或者我应该将其更改为预编译头文件?

EDIT: 编辑:

These are the exceptions: 这些是例外:

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.

These happen with empty projects (without precompiled headers). 这些都发生在空项目中(没有预编译的头文件)。 The code for that is: 代码是:

#include "afxmt.h"

The project using precompiled headers is automatically inserting #include afxmt.h; 使用预编译头的项目会自动插入#include afxmt.h; into compiling process for every source file. 进入每个源文件的编译过程。 If you aren't using precompiled headers you need to add that #include to every source file that is doing something that requires that header. 如果您没有使用预编译头文件,则需要将#include添加到执行需要该头文件的每个源文件。

By default, the Precompiled header file is stadfx.h which has several other includes. 默认情况下,预编译头文件是stadfx.h,其中包含其他几个包含。 You need to manually include the files containing all the function declaration that you use in your code if you are not using precompiled headers. 如果不使用预编译头,则需要手动包含包含代码中使用的所有函数声明的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM