打不开文件Cannot open include file: 'stdafx.h': No such file or directory如何处理

scsnsjsl_cs_dn 2008-11-26 11:30:30
打不开文件Cannot open include file: 'stdafx.h': No such file or directory如何处理
代码如下:
#include "stdafx.h"
#include <iostream>
#include <list>
#include "MyString.h"
using namespace std;
#pragma warning(disable:4786)

int main (void)
{
list<CMyString> Milkshakes;
list<CMyString>::iterator MilkshakeIterator;

Milkshakes.push_back("Chocolate");
Milkshakes.push_back("Strawberry");
Milkshakes.push_front("Lime");
Milkshakes.push_front("Vanilla");

// print the milkshakes
Milkshakes.push_front("The Milkshake Menu");
Milkshakes.push_back("*** Thats the end ***");
for (MilkshakeIterator=Milkshakes.begin();
MilkshakeIterator!=Milkshakes.end();
++MilkshakeIterator)
{
// dereference the iterator to get the element
cout << (const char *)*MilkshakeIterator << endl;
}
return 0;
}

提示错误:Cannot open include file: 'stdafx.h': No such file or directory
另外:#pragma warning(disable:4786)是什么意思?
...全文
2615 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
scsnsjsl_cs_dn 2008-11-26
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 fibbery 的回复:]
提示错误:Cannot open include file: 'stdafx.h': No such file or directory
你的当前目录没有stdafx.h头文件,这个文件是建立工程的时候由编译器自动生成的。

另外:#pragma warning(disable:4786)是什么意思?
禁止4786警告,该警告的具体含义可以查询MSDN或者google一下
[/Quote]
那为什么我的没有自动生成stdafx.h文件呢?
hai040 2008-11-26
  • 打赏
  • 举报
回复
去掉#include "stdafx.h"
这个程序应该不是mfc程序

#pragma warning(disable:4786),不要显示4786号warning
具体msdn pragma
devil_zuiai 2008-11-26
  • 打赏
  • 举报
回复
#include "stdafx.h" 直接去掉。在这个程序里好像没用。
fibbery 2008-11-26
  • 打赏
  • 举报
回复
提示错误:Cannot open include file: 'stdafx.h': No such file or directory
你的当前目录没有stdafx.h头文件,这个文件是建立工程的时候由编译器自动生成的。

另外:#pragma warning(disable:4786)是什么意思?
禁止4786警告,该警告的具体含义可以查询MSDN或者google一下
liqiang_2008 2008-11-26
  • 打赏
  • 举报
回复
我想这个链接可以让你更了解“stdafx.h”:http://baike.baidu.com/view/1344257.htm
其次,warning C4786,
据msdn:识别字符串超过了所允许的最大长度和被截断。调试器不能调试代码,标识符长于255个字符。
注意:
1 这个长于255个字符,别奇怪,那是因为,vc中,很多关键字都是要被编译器替换成调试器能够识别的
‘码’,所以,虽然你定义的变量不长,可有可能出现这个警告;
2 怎么处理,它一般不会对你的程序造成错误,不用管它,或者就在你的代码前加上“#pragma warning(disable:4786) ”----直接屏蔽了它;

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧