C++ 错误 C1083:无法打开包含文件:'stdafx.h':VS 2005 中没有这样的文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5545641/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
error C1083: Cannot open include file: 'stdafx.h': No such file or directory in VS 2005
提问by Abdul Samad
I am new to visual studio.I have created a simple console application and then selected an empty project of c++.
I have pasted the code form
http://www.cprogramming.com/tutorial/opengl_first_windows_app.html
我是 Visual Studio 的新手。我创建了一个简单的控制台应用程序,然后选择了一个空的 C++ 项目。我已经粘贴了代码表格
http://www.cprogramming.com/tutorial/opengl_first_windows_app.html
it is giving the following error error C1083: Cannot open include file: 'stdafx.h': No such file or directory.
它给出了以下错误错误 C1083:无法打开包含文件:'stdafx.h':没有这样的文件或目录。
Can any body help me how ti solve that issue.
任何机构都可以帮助我如何解决这个问题。
Also i have pasted the code from
http://www.cprogramming.com/tutorial/opengl_windows_programming.html
我也粘贴了来自http://www.cprogramming.com/tutorial/opengl_windows_programming.html的代码
and it gives me error in MessageBox function.
它在 MessageBox 函数中给了我错误。
采纳答案by Hans Passant
Fall in the pit of success by using an appropriate project template. Which is Win32 + Win32 Project, don't tick the "Empty project" option on the property page. You'll get pre-generated code for a Win32 application, take a look at it since you might want to keep parts of it. Or just delete it all past the #include for stdafx.h and replace it with the code you want to try. The stdafx.h file is already pre-cooked for you.
使用适当的项目模板陷入成功的陷阱。Win32+Win32项目,属性页的“空项目”选项不要打勾。您将获得 Win32 应用程序的预生成代码,请查看它,因为您可能希望保留其中的一部分。或者只是删除所有超过 stdafx.h 的 #include 并将其替换为您想要尝试的代码。stdafx.h 文件已经为您准备好了。
The second snippet probably fails to compile because the code sample is not using Unicode strings. Put an L in front of the string literal, like L"\tHello world".
第二个片段可能无法编译,因为代码示例未使用 Unicode 字符串。在字符串字面量前面放一个 L,例如 L"\tHello world"。
回答by xDD
"stdafx.h" is the default name for the precompiled header in Visual Studio.
“stdafx.h”是 Visual Studio 中预编译头的默认名称。
If you are not using precompiled headers you can omit that include directive.
如果您不使用预编译头文件,则可以省略包含指令。
See this articleon Wikipedia for an explanation of precompiled headers.
有关预编译头的解释,请参阅维基百科上的这篇文章。