C ++错误:无法打开源文件“stdafx.h” [英] C++ error: cannot open source file "stdafx.h"

查看:1789
本文介绍了C ++错误:无法打开源文件“stdafx.h”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在visual studio上开始了一个新的 EMPTY 项目,当我写了

I started a new EMPTY project on visual studio and when I wrote

#include "stdafx.h"



它给了我一个错误:无法打开源文件stdafx.h



我尝试过:



所以我去了Header Files - >打开 - >现有项目 - >并从另一个项目打开stdfax.h但仍然,它给了我同样的错误。任何人都可以帮忙吗?


it gave me an error : cannot open source file "stdafx.h"

What I have tried:

so I went to Header Files -> Open -> existing Item -> and opened stdfax.h from another project but still , it gave me the same error . anyone can help ?

推荐答案

该文件由New Project向导自动生成,并由编译器用于构建预编译的头文件。在一个空的项目中,它将不存在。
That file is generated automatically by the New Project wizard, and is used by the compiler to build the pre-compiled headers file. In an empty project it will not exist.


据我所知,它是一个预编译的头文件,它有助于加速C ++应用程序。注意那里的双引号表示它是用户添加的头文件,通常头文件将在<>中。并且对于用户添加的头文件#include头文件的位置stdafx通常由编译器在默认项目位置添加,对于空项目,编译器根本不会创建任何文件,因此您需要添加New Item(头文件) )使用stdafx.h的名称使应用程序为您工作。请记住,这不会加速C ++应用程序。





添加stdafx.h的正确方法是在项目设置中使用预编译的头文件。





随意提出疑问
To my knowledge it a pre-compiled header file, It helps in speeding up the C++ application. Notice the double quotes "" over there that means it is a user added header file generally headers will be in <> and for user added header file #include"location of the header file" stdafx is generally added by the compiler in a default project location and for an empty project the compiler wont create any files at all so you need to add New Item(Header file) with the name of stdafx.h to make the application work for you. Remember this will not speed up the C++ application.


The proper way of adding stdafx.h is by mentioning use pre-compiled header file in your Project settings.


Feel free to ask any doubts


请出示您的代码..



我认为你定义了#includeafxwin.h这就是为什么你得到错误。



你应该在afxwin中定义。 h而不是
please show your code..

I think you have defined #include"afxwin.h" thats why your getting error.

you should define in "afxwin.h" instead of


这篇关于C ++错误:无法打开源文件“stdafx.h”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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