VS2008 win32 project defaults - remove precompiled default headers

I went through each option to try and find a way to force the IDE to allow me to create a new win32pject without precompiled headers. I read every topic on this forum with the words "prepmpiled headers" in it, and the closest I got:

Precompiled Headers

Using 2008 pro (not express, although the behavior seems to be similar) I will go to:

File β†’ Create β†’ Project

This opens the New Project dialog box in which I select Visual C ++ Win32 Project, enter a name and click OK.

I got the "Win32 Application Wizard." If the application type is set to "Windows Application", the application settings panel will not allow me to disable precompiled headers. The checkmark is grayed out. IF I select "Console Application", I can remove it, but create a graphical application.

When I click Finish, I get 6 yards of code in xxx.cpp, four header files and the required stdafx.cpp.

Maybe I can delete and delete all these things, as well as go into properties and disable PCH, but this hasssel for many small projects that I want to write.

I just need an empty project that will compile into a win32 application, so how do I change the default value for PCH to NONE?

+4
source share
6 answers

You can make your own template for this, or you can change it by default. The corresponding wizard can be found here:

C:\Program Files\Microsoft Visual Studio 9.0\VC\VCWizards\AppWiz\Generic\Application 

Obviously, if you are going to edit the default template, first back up the folder.

I will show you how to start editing.

First of all, you need to tell the script wizard that you do not need precompiled headers. Edit this file in your favorite text editor:

 \scripts\1033\default.js 

Find this line:

 var Pch = wizard.FindSymbol("PRE_COMPILED_HEADER"); 

and comment on some lines below this:

 // if ((strAppType == "LIB" || ((strAppType == "CONSOLE") && // !wizard.FindSymbol("SUPPORT_MFC") && !wizard.FindSymbol("SUPPORT_ATL"))) && !Pch) { AddFilesToProjectWithInfFile(selProj, strProjectName); SetNoPchSettings(selProj); } // else // { // AddFilesToProjectWithInfFile(selProj, strProjectName); // SetCommonPchSettings(selProj); // } 

Now open this file:

 \templates\1033\Templates.inf 

and find the first occurrence of [!else] and delete these 3 lines below:

 stdafx.h targetver.h stdafx.cpp 

This will give you a project without stdafx.cpp / .h or targetver.h, and the CPP file will not try to use PCH. However, it will not be created because we have not added #includes to the corresponding header files. I will leave this for you to find out:

(you can edit files that are generated automatically by modifying files in \templates\1033 )

+8
source

either select an empty project, or create your own wizard in which you use the template. Since you say that you do not want to change properties all the time, I also strongly recommend using property sheets (vsprops). Thus, you create an empty project, add the sheets of properties you need, and you are ready to go. No longer works with properties, and each project uses the same set.

+2
source

Check the "Empty project" checkbox in the "Advanced Settings" dialog box of the "Application Settings" dialog box.

+1
source

The "Empty project" option will create a project without precompiled headers. At least this is what I get in Visual Studio 2008 SP1.

It is true that "Use precompiled headers" remains checked, but the project will have the property UsePrecompiledHeader = "0" and the wizard will not create the files.

+1
source

I'm bouncing a bit on this winning side, as I have the same problems for VS2010.

I am not sure if this solution will be applied for VS2008.

Since the tools do not have parameters or parameters that would allow me to default to an empty project, I searched and found the following:

in folder

 C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\VCWizards\AppWiz\Generic\Application\html\1033 

there is a file called default.htm

there are two lines in the </HEAD> section:

 <SYMBOL NAME="EMPTY_PROJECT" TYPE=checkbox VALUE=false></SYMBOL> <SYMBOL NAME="PRE_COMPILED_HEADER" TYPE=checkbox VALUE=true></SYMBOL> 

which I replaced with

 <SYMBOL NAME="EMPTY_PROJECT" TYPE=checkbox VALUE=true></SYMBOL> <SYMBOL NAME="PRE_COMPILED_HEADER" TYPE=checkbox VALUE=false></SYMBOL> 

(in other words, I just switched true and false to these lines) and now I have an empty default project when creating a console application.

I don’t know what consequences it will affect when I do something other than console applications, but since I saved the original file, I can just go back to the old M $ settings.

+1
source

You can simply select the "empty project" in the "Advanced Options" section. Then you get a project without precompiled headers and without auto-generated files.

I don't know what it is with Microsoft's obsession with forcing precompiled headers even in the smallest test project. Presumably, it is based on the same philosophy that gave us the macro-hell, which is windows.h, or the way that even an empty project overrides two dozen project settings, which makes property sheets almost useless.

I suspect that there is a strong mafia in the Microsoft development team that does everything possible so that Visual Studio does not become a useful tool for C ++ developers. So far they are doing very well with this.

-one
source

All Articles