VS2008 win32 项目默认值 - 删除默认预编译头文件 [英] VS2008 win32 project defaults - remove default precompiled headers

查看:36
本文介绍了VS2008 win32 项目默认值 - 删除默认预编译头文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了所有选项,试图找到一种方法让 IDE 允许我创建一个没有预编译头的新 win32pject.我已经阅读了这个论坛上的每个帖子,里面都有precpmpiled headers"字样,我得到的最接近的是:

I have been through every option to try to find a way to get the IDE to let me create a new win32pject without precompiled headers. I have read every thread on this forum with the words "precpmpiled headers" in it and the closest I got was:

预编译头

使用 2008 pro(不是 express,虽然行为似乎相似)我去:

Using 2008 pro (not express, althought the behaviour seems to be similar) I go to:

文件 -> 新建 -> 项目

File -> New -> Project

这将打开新建项目"对话框,我在其中选择Visual C++ Win32 项目",输入名称并点击确定".

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

然后我得到Win32 应用程序向导".将应用程序类型设置为Windows 应用程序"后,应用程序设置窗格将不允许我取消选中预编译的头文件.复选框是灰色的.如果我选择控制台应用程序",我可以取消选中它,但我正在创建一个 GUI 应用程序.

THen I get the "Win32 Application Wizard". With the Application Type set to "Windows Application", the application settings pane will not allow me to uncheck the pre-compiled headers. THe check box is greyed out. IF I choose "Console Application" I can uncheck it, but I am creating a GUI app.

当我单击完成"时,我在 xxx.cpp、四个头文件和强制性 stdafx.cpp 中得到 6 码代码.

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

也许我可以删除和删除所有这些东西,然后进入属性并关闭 PCH,但这对于我想编写的许多小项目示例来说是一个麻烦.

Perhaps I could remove and delete all this stuff and the go into the properties and turn off PCH, but thats a hasssel for the many small project examples I want to write.

我只想要一个可以编译为 win32 应用程序的空项目,那么如何将 PCH 默认值更改为 NONE?

I just want an empty project that will compile to a win32 app, so how do i change the PCH default to NONE?

推荐答案

您可以制作自己的模板来执行此操作,也可以编辑默认模板.相关向导可以在这里找到:

You could make your own template to do this, or you could edit the default one. The relevant wizard can be found here:

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

显然,如果您要编辑默认模板,请先备份文件夹.

Obviously if you're gonna edit the default template, backup the folder first.

我将向您展示如何开始编辑它.

I'll show you how to get started on editing it.

首先,您需要告诉向导脚本您不想要预编译的头文件.在您喜欢的文本编辑器中编辑此文件:

First of all you need to tell the wizard script that you don't want precompiled headers. Edit this file in your favourite text editor:

\scripts\1033\default.js

找到这一行:

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

并像这样注释掉它下面的一些行:

and comment out some of the lines below it like 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);  
//  }

现在打开这个文件:

\templates\1033\Templates.inf

并找到第一次出现的 [!else] 并删除它下面的这 3 行:

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

stdafx.h
targetver.h
stdafx.cpp

这会给你一个没有 stdafx.cpp/.h 或 targetver.h 的项目,并且 CPP 文件不会尝试使用 PCH.但是它不会构建,因为我们没有在适当的头文件中添加任何 #includes.我会把它留给你弄清楚:)
(您可以通过修改\templates\1033中的文件来编辑自动生成的文件)

This will give you a project without stdafx.cpp/.h or targetver.h, and the CPP file will not try to use a PCH. However it won't build because we haven't added any #includes to the appropriate header files. I'll leave that for you to figure out :)
(you can edit the files that get generated automatically by modifying the files in \templates\1033)

这篇关于VS2008 win32 项目默认值 - 删除默认预编译头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆