Rud*_*dis 4 c++ compiler-errors visual-studio-2015
我最近购买了Bjarne Stroustrup撰写的文章“编程:使用C ++的原理和实践”,并且一直在关注它。我目前停留在早期项目中,我需要输出一些文本字符串。在Windows 10 Lenovo Yoga 2 Pro笔记本电脑上使用Visual Studio Community 2015更新1,我尝试编译该项目,但遇到了以下错误:
“无法打开预编译的头文件:Debug \ Finding the Upstairs Bathroom.pch':没有此类文件或目录”。该项目的名称恰当地命名为“ Finding the Upstairs Bathroom.cpp”。这是代码:
// I have the headers "stdafx.h" as well as this specific header lib
// Bjarne Stroustrup created and which I had linked
// called "../../std_lib_facilities.h", which contains the standard C++ lib functions.
(#) define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS 1
int main()`// Main function`
{
cout << "Take the key out of your right pants pocket\n"; // Outputs string of text
cout << "Unlock the front door of the house\n";
cout << "Open the front door and step inside\n";
cout << "Lock the front door using the key\n";
cout << "Move up the stairs, taking them two at a time\n";
cout << "Walk to the second door on the left and face it directly\n";
cout << "Using the door handle, turn it and push the door forward\n";
cout << "Enter the bathroom while leaving the door open behind you\n";
keep_window_open();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
如果有人能够弄清楚我的错误,我将不胜感激。
小智 11
确保 StdAfx.cpp>右键单击>属性(与 +enter 不同)具有'Precompiled Header'='Create /Yc'
其余的 .cpp 文件应该有'Precompiled Header'='Use /Yu'
有两种解决方案:
重建整个项目。这应该(重新)创建预编译的头文件(或Build/Clean Solution首先选择)。
关闭预编译的头文件。Project settings / C/C++ / Precompiled headers / Not Using Precompiled Headers。