Precompiled Headers with Mixed C and C++ Precompiled Headers with Mixed C and C++ c c

Precompiled Headers with Mixed C and C++


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

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


You might be able to create two precompiled headers in your project. There's a property on each source file that determines if it's going to use a precompiled header, or generate a precompiled header - try setting two different sources to generate a header.


Zuuum's Answer

Not using precompiled headers

Apologies to Zuuum for such a blatant rip off of his answer, but 7 years later it is still buried as a comment. Bo Perrson tells us what to do

So don't use precompiled headers for that single file!
It will have separate compilation options anyway.

and Zuuum tells us how

Extra Info: Select the file you don't want to use "Precompiled Header" from the Solution Explorer
Right Click
Under Precompiled Headers Option, Select Not Use Precompiled Header
– Zuuum Feb 19 '12 at 18:34

I've made tiny edits - they are not direct quotes. The reason for my change is you may want to exclude a C or a C++ file from using precompiled headers for a particular case. Bo assumes C++ as it's a direct answer to the question. Zuuum assumes C, and that's the case for me and in my illustration. It could be either in practice.

It's understandable but annoying that the location of options in menus changes from one release of visual studio to another, but here is the location of the menu item in my current visual studio (2019).