Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Precompiled Headers with Mixed C and C++

Tags:

I am using pre-compiled headers in my project in C but we are integrating a .CPP file into the project.

Here's the error:

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 

We only need a single .CPP compiled in our project, but we really need the pre-compiled header to save compile times (Windows.h and more).

How should I organize my project to do this?

like image 365
James Linden Avatar asked Jan 19 '12 22:01

James Linden


People also ask

Should you use precompiled headers?

Usage of precompiled headers may significantly reduce compilation time, especially when applied to large header files, header files that include many other header files, or header files that are included in many translation units.

How do you Precompile headers?

The compiler options for precompiled headers are /Y . In the project property pages, the options are located under Configuration Properties > C/C++ > Precompiled Headers. You can choose to not use precompiled headers, and you can specify the header file name and the name and path of the output file.

Why does C have headers?

Header files serve two purposes. System header files declare the interfaces to parts of the operating system. You include them in your program to supply the definitions and declarations you need to invoke system calls and libraries.


1 Answers

So don't use precompiled headers for that single file!

Being a .cpp file, it will have separate compilation options anyway.

like image 155
Bo Persson Avatar answered Oct 20 '22 19:10

Bo Persson