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

45,215

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.

Share:
45,215

Related videos on Youtube

Admin
Author by

Admin

Updated on February 23, 2020

Comments

  • Admin
    Admin about 4 years

    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.

  • rayryeng
    rayryeng over 7 years
    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.