具有混合C和C++的预编译头

Jam*_*den 21 c c++ precompiled-headers visual-studio

我在C项目中使用预编译的头文件,但我们正在将.CPP文件集成到项目中.

这是错误:

Error   1   fatal error C1853: 'Debug\MuffinFactory.pch' precompiled header
file is from a previous version of the compiler, or the precompiled header is C++
 and you are using it from C (or vice versa)    
c:\users\blake\desktop\projects\muffinfactory\source\main.cpp   1
Run Code Online (Sandbox Code Playgroud)

我们只需要在我们的项目中编译一个.CPP,但我们确实需要预编译的头来节省编译时间(Windows.h等).

我应该如何组织我的项目呢?

Bo *_*son 19

所以不要为该单个文件使用预编译头文件!

作为.cpp文件,无论如何它都将有单独的编译选项.


Mar*_*som 5

您可以在项目中创建两个预编译头.每个源文件都有一个属性,用于确定是否要使用预编译头,或生成预编译头 - 尝试设置两个不同的源来生成头.

  • 额外信息:选择.c文件,您不想使用解决方案资源管理器中的"预编译标题" - >右键单击 - >在预编译标题选项下,选择不使用预编译标题 (10认同)