为什么我不能在 Visual Studio 中禁用预编译头的使用? [英] Why can't I disable the use of precompiled headers in Visual Studio?

查看:48
本文介绍了为什么我不能在 Visual Studio 中禁用预编译头的使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Visual Studio Express 2013 中为 Windows 桌面(v12.0.30723.00 更新 3)创建一个 C++ 静态库.我不想在我的库中使用预编译的头文件.我无法编译没有错误的最基本的项目.

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.

问题很容易复制如下:

  1. 文件->新建项目
  2. 选择模板->Visual C++->CLR->类库.单击确定"在默认位置创建 ClassLibrary1.
  3. 在 Project->Properties 中,转到 Configuration Properties->C/C++->Precompiled Headers,并将 Precompiled Header 选项设置为Not Using Precompiled Headers".
  4. 编辑文件 AssemblyInfo.cpp 和 ClassLibrary1.cpp,并注释掉每个文件顶部的 #include "stdafx.h".
  5. 在解决方案资源管理器中,右键单击 Stdafx.cpp 并选择从项目中排除".
  6. 重新构建解决方案.

我收到以下两个错误:

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

我是否遗漏了一个步骤,或者我是否在此版本的 Visual Studio 中发现了错误?

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

推荐答案

有时,您可能会花费数小时的时间来思考具有非常基本解决方案的问题.在这种情况下,活动配置是调试,但我正在更改发布配置的预编译头选项.当我更改调试配置中的选项时,瞧!没有更多的错误.

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.

这篇关于为什么我不能在 Visual Studio 中禁用预编译头的使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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