VS2008 win32项目默认设置-删除默认预编译头

发布于 2024-08-08 05:22:42 字数 663 浏览 3 评论 0原文

我已经尝试了所有选项,试图找到一种方法让 IDE 让我创建一个没有预编译头的新 win32pject。我已经阅读了这个论坛上的每个帖子,其中包含“precpmpiled headers”一词,我得到的最接近的是:

预编译标头

使用 2008 pro(不是 Express,尽管行为似乎相似)我转到:

文件 ->新->项目

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

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

当我单击 Finish 时,我在 xxx.cpp 中获得了 6 码代码、四个头文件和必需的 stdafx.cpp。

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

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

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:

Precompiled Headers

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

File -> New -> Project

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

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.

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

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.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

梦毁影碎の 2024-08-15 05:22:42

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

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

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

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

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

\scripts\1033\default.js

找到此行:

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

并注释掉其下面的一些行,如下所示:

//  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 行:

stdafx.h
targetver.h
stdafx.cpp

这将为您提供一个没有 stdafx.cpp/.h 或 targetver.h 的项目,并且 CPP 文件不会尝试使用 PCH。但是它不会构建,因为我们没有将任何 #include 添加到相应的头文件中。我会把这个留给你去解决:)
(您可以通过修改\templates\1033中的文件来编辑自动生成的文件)

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

Find this line:

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);  
//  }

Now open this file:

\templates\1033\Templates.inf

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

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 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)

夕色琉璃 2024-08-15 05:22:42

选择一个空项目,或者创建您自己的使用模板的向导。既然你说你不想一直改变属性,我也强烈建议使用属性表(vsprops)。这样,您就可以创建一个空项目,添加所需的属性表,然后就可以开始了。不再需要摆弄属性,每个项目都使用相同的集合。

either choose an empty project, or create your own wizard in which you use a template. Since you say you don't want to change properties the whole time, I'd also strongly suggest using property sheets (vsprops). This way, you create an empty project, add the property sheets you want, and you'r ready to go. No more fiddling with properties, and each project uses the same set.

青芜 2024-08-15 05:22:42

在“应用程序设置”对话框的“附加选项”中选中“空项目”复选框。

Mark the "Empty Project" check box in the "additional options", in the Application Settings dialog.

情场扛把子 2024-08-15 05:22:42

“空项目”选项将创建一个没有预编译头的项目。至少,这是我在 Visual Studio 2008 SP1 上得到的。

确实,“使用预编译头”仍然处于选中状态,但项目将具有属性 UsePrecompiledHeader="0" 并且向导不会创建文件。

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

It's true that the "Use precompiled headers" remain checked, but the project will have the property UsePrecompiledHeader="0" and the wizard won't create the files.

三生池水覆流年 2024-08-15 05:22:42

我很晚才加入这个潮流,因为我在 VS2010 中也遇到了同样的问题。

我不确定这个解决方案是否适用于 VS2008。

由于工具下没有允许我默认为空项目的设置或选项,我四处搜索并发现以下内容:

在文件夹中

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

有一个名为 default.htm 的文件

< 中 /code> 部分,有两行:

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

我替换为

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

(换句话说,我只是在这些行上切换了 truefalse
现在,当我创建控制台应用程序时,默认情况下我有一个空项目。

我不知道当我执行控制台应用程序以外的操作时会产生什么影响,但由于我保存了原始文件,我可以恢复到旧的 M$ 设置。

I'm jumping way late on this bandwagon, as I'm having the same issues for VS2010.

I'm not sure if this solution would apply for VS2008.

Since there are no settings or options under tools which would enable me to default to an empty project, I searched around and found the following:

in the folder

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

there is a file named default.htm

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

<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 on those lines)
and now I have an empty project by default when I create a console app.

I don't know the repercussions as to what it will affect when I do something other than console apps, but since I saved the original file, I can just revert to the old M$ settings.

匿名。 2024-08-15 05:22:42

您只需选择“其他选项”下的“空项目”即可。然后你会得到一个没有预编译头、也没有自动生成文件的项目。

我不知道微软对即使在最小的测试项目中也强制使用预编译头的痴迷是怎么回事。据推测,它的原理与给我们带来宏地狱的windows.h相同,或者甚至是一个空项目也会覆盖两打项目设置,使属性表几乎毫无用处。

我怀疑 Microsoft 开发人员部门内部存在一个强大的黑手党,他们正在竭尽全力阻止 Visual Studio 成为 C++ 开发人员的有用工具。到目前为止,他们做得非常好。

You can just select 'empty project' under 'additional options'. Then you get a project with no precompiled headers, and no autogenerated files.

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

I suspect there's simply a strong mafia inside Microsoft's developer division, who's doing everything they can to prevent Visual Studio from becoming a useful tool for C++ developers. So far, they're doing a very good job of it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文