Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I disable the use of precompiled headers in Visual Studio?

I'm trying to create a C++ static library in Visual Studio Express 2013 for Windows Desktop (v12.0.30723.00 Update 3). I don't want to use precompiled headers in my library. I can't get the most basic project to compile without errors.

The problem can be easily duplicated as follows:

  1. File->New Project
  2. Select Templates->Visual C++->CLR->Class Library. Click OK to create ClassLibrary1 in the default location.
  3. In Project->Properties, go to Configuration Properties->C/C++->Precompiled Headers, and set the Precompiled Header option to "Not Using Precompiled Headers".
  4. Edit the files AssemblyInfo.cpp and ClassLibrary1.cpp, and comment out the #include "stdafx.h" at the top of each file.
  5. In the Solution Explorer, right-click on Stdafx.cpp and select "Exclude from Project".
  6. Rebuild the solution.

I get the following two errors:

1   error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?   AssemblyInfo.cpp   39   1   ClassLibrary1
2   error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?   ClassLibrary1.cpp   7   1   ClassLibrary1

Am I missing a step, or have I found a bug in this version of Visual Studio?

like image 465
sifferman Avatar asked Dec 11 '22 02:12

sifferman


1 Answers

Sometimes you can spend hours scratching your head over something that has a very basic solution. In this case, the Active configuration was Debug, but I was changing the Precompiled Header option for the Release configuration. When I changed the option in the Debug configuration, voila! no more errors.

like image 132
sifferman Avatar answered May 21 '23 00:05

sifferman