预编译头 error C2857 ?
环境:Vc.Net2003、MFC对话框项目。
经过如下操作:
项目——属性——C/C++——预编译头——
选择使用预编译头(/Yu);
通过文件创建/使用:把本来填写的文件“stdafx.h”改为:“ABL_AfxStd.h”。(并且我把stdafx.h内的所有,包括关于MFC的头文件的包含都原封不动剪贴到ABL_AfxStd.h中)
然后 编译、全部编译 都按过了,编译器都是提示:
正在编译...
stdafx.cpp
g:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlsimpstr.h(509) : error C2857: 在源文件中没有找到用 /YcABL_AfxStd2.h 命令行选项指定的“#include”语句
怎么解决呢?谢谢!
问题点数:100、回复次数:14Top
1 楼hai_feng(海风)回复于 2005-05-19 13:42:27 得分 0
但是此时,当我选择 自动生成(/Yx) 并且 文件名填空,却是可以编译通过的。但是以后每次编译的速度比之前慢了。希望能够在转移了stdafx.h文件名后能够继续使用手工控制模式。Top
2 楼sinall()回复于 2005-05-19 14:06:12 得分 0
Compiler Error C2857
'#include' statement specified with the /Ycfilename command-line option was not found in the source file
The /Yc command-line option specified the name of an include file, but that file was not included in the source file being compiled.
Make sure that the filename specified in the /Yc command-line option corresponds to an include file specified in an #include statement in the current source file.
This error can be caused by having the #include statement in a conditional compilation block that is not compiled.
Top
3 楼oyljerry(【勇敢的心】→ ㊣提拉米苏√㊣)回复于 2005-05-19 14:06:57 得分 1
stdafx就是预编译文件,这样下次编译时就能加快编译速度
Top
4 楼hai_feng(海风)回复于 2005-05-19 14:19:58 得分 0
楼上2位能说清楚点吗?我只是把文件名改名了,但文件的内容是没有改变的。但就不能编译通过了。
怎么还要说没有找到#include呢?Top
5 楼younggle(洋溢)回复于 2005-05-19 14:29:44 得分 0
不要改名字,编译器默认的文件是stdafx.h。并且首先要编译这个文件的。
建议改回去。Top
6 楼hai_feng(海风)回复于 2005-05-19 15:14:57 得分 0
发现了个新原因:大家留意顶楼中的错误:
g:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlsimpstr.h(509) : error C2857: 在源文件中没有找到用 /YcABL_AfxStd2.h 命令行选项指定的“#include”语句
是在文件 atlsimpstr.h(509行) 发生的。而MFC对话框项目中的CString是默认通过使用ATL实现的。而我再查了一下,MFC对话框项目属性——常规中是默认不使用ATL的,估计是编译器在我改文件名后认为我没有正确明确使用atl。这些是我的估计,但是如何正确使用atl我还是搞不懂,请高手指教。
另外,to younggle(洋溢)
不能改名的,微软的编译器还设这个选项干嘛?帮助文档里说是可以改名的。Top
7 楼hai_feng(海风)回复于 2005-05-19 17:29:20 得分 0
upTop
8 楼fanqing(火影忍者+28%(准备学习进程/线程))回复于 2005-05-19 17:32:37 得分 1
stdafx就是预编译文件,在vc6中可以改名(即指定预编译文件)--vc7应该也有此功能(具体如何操作不清楚)Top
9 楼hai_feng(海风)回复于 2005-05-19 21:43:40 得分 0
up
Top
10 楼hai_feng(海风)回复于 2005-05-20 11:30:24 得分 0
up
Top
11 楼greenteanet(扎扎实实打基础,保持一颗平常心。)回复于 2005-05-20 12:23:56 得分 1
upTop
12 楼hai_feng(海风)回复于 2005-05-20 15:40:33 得分 0
up
Top
13 楼hai_feng(海风)回复于 2005-05-20 17:28:46 得分 0
楼上上上...的,直接贴帮助好像没什么意义啊,你要的话我把十多G的Msdn贴给你看都行啊。
很简单的就可以试试了,只要把你工程中的stdafx.h改名 或 复制一份再加入到项目中,就会出现我说的问题了,你真的能解决才给我发言好吗,否则我觉得你发言因改声明为“UP”,否则不是帮忙而是以投机的方式浪费大家时间。Top
14 楼fireseed(【VC无敌,英明神武,千秋万代,一统江湖!】—奶油狗)回复于 2005-05-21 20:44:20 得分 97
可以改名,方法如下:
1. 将原工程中的stdafx.h和stdafx.cpp从当前工程中删掉
2. 将stdafx.h和stdafx.cpp改为你想要的任何名子,比如myafx.h和myafx.cpp
3. 将myafx.cpp中的“#include "stdafx.h"”改为“#include "myafx.h"”
4. 将myafx.h和myafx.cpp再分别加入到当前工程中
5. 进入工程属性设置 -> C/C++ -> 预编译头,更改stdafx.h为myafx.h
6. 进入解决方案管理器,在myafx.cpp上单击右键 -> 属性 -> C/C++ -> 预编译头,将第一项设为“创建预编译头。
7. 将工程中所有的#include "stdafx.h"改为#include "myafx.h"
8. 保存、编译,修改成功
Top




