locked
c header error C1853

    Question

  • I have a c program that I wanted to build in Visual Studio.  The only issue I have so far is that I get error C1853: 'Debug\MyProj.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).

    I found this article: http://msdn.microsoft.com/en-us/library/5t8yz59b.aspx 
    and another article which suggested some switches like /Tc

    I loaded Visual Studio 2010 and don't really know how to set the switches or resolve this issue.  Any help is appreciated.
    Monday, March 15, 2010 1:12 PM

Answers

  • I changed the option to not use Precompiled headers.  This resolved my issue.  Perhaps after every thing is working, I will try to use Precompiled headers again and see if the issue persists.
    • Marked as answer by Boblam Tuesday, March 23, 2010 12:37 PM
    Tuesday, March 23, 2010 12:37 PM

All replies

  • Try rebuilding or cleaning the solution, this will delete the pch file.
    If this doesn't work, go to your project directory, in the debug directory find and delete the .pch file and then build the project again.
    Visit my (not very good) blog at http://c2kblog.blogspot.com/
    Monday, March 15, 2010 4:55 PM
  • That didn't resolve the issue.  I think the issue resolves around the following.


    I have created a C++ Win32 Project and basically imported files from an old C project.  The initial file MyProj.cpp also creates a stdafx.cpp file.  I reference some C header files in the stdafx.h file. 

    I guess this breaks down into two basic questions:

    1. I have created a MyProj.cpp file and esentially commented it out.  I have copied another C file in MyProj.c which is the entry point for the C program.  I would like to use this as the entry point and not even use the MyProj.cpp file.  How do I do this?

    2. This project also has a stdafx.cpp file.  I'm guessing this should also be something like stdafx.c.  When I tried this, the build could no longer find the debug\Myproj.pch file.  Even if I created one, it would delete it during the build and have the same error.

    I believe I have all of the C files in the solution / project.  I really need help in initially setting up the C++ project to basically be a C project.  Any suggestions are welcome.

    Tuesday, March 16, 2010 1:02 AM
  • I have a c program that I wanted to build in Visual Studio.  The only issue I have so far is that I get error C1853: 'Debug\MyProj.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).

    I found this article: http://msdn.microsoft.com/en-us/library/5t8yz59b.aspx 
    and another article which suggested some switches like /Tc

    I loaded Visual Studio 2010 and don't really know how to set the switches or resolve this issue.  Any help is appreciated.

    Hi Boblam,

    Here are some options that you can try to see if changing them can resolve your problem.
    1. Select the project node in Solution Explorer, right click, select "Properties->Configuration Properties->C/C++->Precompiled Headers". You can see the option settings for precompiled header, you may want to make sure those setttins make sense to your new C project.
    2. Select the project node in Solution Explorer, right click, select "Properties->Configuration Properties->C/C++->Advanced->Compile As". If you project/codes are in C, then select "Compile as C Code (/TC)".


    Thanks,
    Jianhua
    Tuesday, March 16, 2010 1:46 AM
  • Hello,

    Have you got any progress on this issue? If there is anything else we can help, welcome to post here.

    Thanks,
    Rong-Chun Zhang
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, March 23, 2010 5:23 AM
  • I changed the option to not use Precompiled headers.  This resolved my issue.  Perhaps after every thing is working, I will try to use Precompiled headers again and see if the issue persists.
    • Marked as answer by Boblam Tuesday, March 23, 2010 12:37 PM
    Tuesday, March 23, 2010 12:37 PM
  • I have a c program that I wanted to build in Visual Studio.  The only issue I have so far is that I get error C1853: 'Debug\MyProj.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).

    I found this article: http://msdn.microsoft.com/en-us/library/5t8yz59b.aspx  
    and another ac3 article which suggested some switches like /Tc

    I loaded Visual Studio 2010 and don't really know how to set the switches or resolve this issue.  Any help is appreciated.

    Hi Boblam,

    Here are some options that you can try to see if changing them can resolve your problem.
    1. Select the project node in Solution Explorer, right click, select "Properties->Configuration Properties->C/C++->Precompiled Headers". You can see the option settings for precompiled header, you may want to make sure those setttins make sense to your new C project.
    2. Select the project node in Solution Explorer, right click, select "Properties->Configuration Properties->C/C++->Advanced->Compile As". If you project/codes are in C, then select "Compile as C Code (/TC)".


    Thanks,
    Jianhua

    It helps me figure it out. Thanks. The problem has annoyed me for several days.
    Tuesday, July 27, 2010 8:30 AM
  • Another quick fix that is NOT OUT THERE is to rename you .c files into .cpp and .h files into .hpp.  This way you don't have to play with any compiler options.
    Sunday, April 29, 2012 9:19 AM