Compile C files in C++ project which do not use precompiled header?

user1182183 picture user1182183 · Dec 14, 2012 · Viewed 43.6k times · Source

Can I disable precompile header for .c files in my C++ project?

I'm getting these errors when I want to add the .C files to my program for a scripting virtual/abstract machine which is in C:

Error 1 error C1853: 'Release\pluginsa.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) Z:\Profile\Rafal\Desktop\samod\source\amx\amx.c 1 1 pluginsa

All other stuff is C++ and uses my precompiled header.

Answer

Praetorian picture Praetorian · Dec 14, 2012

In the Solution Explorer window right click on the *.c file(s) and select Properties. Go to C / C++ -> Precompiled Headers and set the Precompiled Header option to Not Using Precompiled Headers.

Also, unless you actually need precompiled headers, I'd say turn it off project-wide.

Another option would be to compile your C files as C++ and keep using the precompiled headers. To do that, right click on the project name (or each .c file name), and set C / C++ -> Advanced -> Compiles As to Compile as C++ code.