49

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.

1 Answers1

106

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.

Praetorian
  • 106,671
  • 19
  • 240
  • 328
  • Thank you. This worked for me. It's very annoying that VS has this enabled by default and I couldn't figure out how to disable this. – rayryeng Feb 03 '17 at 05:48