4
votes

I have mixed C++ project (managed and unmanaged). The unmanaged is using lots of libraries such as boost. They are all included in the stdafx.h file. I am trying to have two separate precompiled headers, one managed (stdafx.h) and one for unmanaged (stdafxManaged.h). How ever when I include the stdafxManaged.h from my Managed code I get an error saying:

error C2855: command-line option '/clr' inconsistent with precompiled header

So I turn the Common Language RunTime Support (/clr) on for the stdasfManaged.cpp and get the following error:

error C1852: 'Debug\xxx.pch' is not a valid precompiled header file

Where xxx is the name of the project and it shows as an error for all of the unmanaged .cpp files in the project.

Does anyone know how to fix this error or have any link to a tutorial which tells you how to setup multiple precompiled headers for a mixed code?

1
As far as I know, multiple precompiled headers are not supported.brian beuning
If that is the case then Ill be very annoyed but I guess it would explain the .pch file conflict. Do you know where I could find more details about this?Miro Bucko

1 Answers

4
votes

This is actually possible. Make sure that /clr is active for the .cpp file and both the precompiled header file and precompiled header output file settings are different from the regular stdafx.h and $(TargetName).pch.