CStdioFile 未声明的标识符
使用 CStdioFile 类型时,我无法编译代码。我已经包含了 afx.h 头文件,但仍然收到错误。我想做的是编写一个包含整个 xml 文档的 cstring 文件。这个 cstring 内部包含注释,但是当我使用其他对象(例如 wofstream)将其写入文件时,这些注释由于某种原因被删除。这就是为什么我现在尝试使用 CStdioFile 将其写入文件。如果有人可以帮助我解释为什么我无法使用 CStdioFile 编译代码,或者以任何其他方式编写包含 xml 注释的 cstring 到文件中,请告诉我!下面是我使用 CStdioFile 的代码:
CStdioFile xmlFile;
xmlFile.Open( "c:\\test.txt", CFile::modeCreate | CFile::modeWrite | CFile::typeText );
xmlFile.WriteString( m_sData );
xmlFile.Close();
以及我的错误: 错误 C2065:“CStdioFile”:未声明的标识符 错误 C2065:“modeCreate”:未声明的标识符 错误 C2065:“modeWrite”:未声明的标识符 错误 C2065:“typeText”:未声明的标识符 错误 C2065:“xmlFile”:未声明的标识符 错误 C2146:语法错误:缺少 ';'在标识符“xmlFile”之前 错误 C2228:“.Close”左侧必须具有类/结构/联合类型类型为“未知类型” 错误 C2228:“.Open”左侧必须具有类/结构/联合类型类型为“未知类型” 错误 C2228:“.WriteString”左侧必须具有类/结构/联合类型类型为“未知类型” 错误 C2653:“CFile”:不是类或命名空间名称 错误 C2653:“CFile”:不是类或命名空间名称 错误 C2653:“CFile”:不是类或命名空间名称 错误 C3861:“xmlFile”:未找到标识符,即使使用依赖于参数的查找 错误 C3861:“xmlFile”:未找到标识符,即使使用依赖于参数的查找 错误 C3861:“xmlFile”:未找到标识符,即使使用依赖于参数的查找
I am unable to compile my code when using a CStdioFile type. I have included the afx.h header file but I am still receiving errors. What I am trying to do is write a cstring that contains an entire xml document to file. This cstring contains comments inside of it, but when I use other objects such as wofstream to write it to file, these comments are striped out for some reason. So that is why I am trying to write this to file using CStdioFile now. If anyone can help me out as to why I cannot compile my code using CStdioFile, or any other way to write a cstring that contains xml comments to file, please let me know! Below is my code using CStdioFile:
CStdioFile xmlFile;
xmlFile.Open( "c:\\test.txt", CFile::modeCreate | CFile::modeWrite | CFile::typeText );
xmlFile.WriteString( m_sData );
xmlFile.Close();
And my errors:
error C2065: 'CStdioFile' : undeclared identifier
error C2065: 'modeCreate' : undeclared identifier
error C2065: 'modeWrite' : undeclared identifier
error C2065: 'typeText' : undeclared identifier
error C2065: 'xmlFile' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'xmlFile'
error C2228: left of '.Close' must have class/struct/union type type is ''unknown-type''
error C2228: left of '.Open' must have class/struct/union type type is ''unknown-type''
error C2228: left of '.WriteString' must have class/struct/union type type is ''unknown-type''
error C2653: 'CFile' : is not a class or namespace name
error C2653: 'CFile' : is not a class or namespace name
error C2653: 'CFile' : is not a class or namespace name
error C3861: 'xmlFile': identifier not found, even with argument-dependent lookup
error C3861: 'xmlFile': identifier not found, even with argument-dependent lookup
error C3861: 'xmlFile': identifier not found, even with argument-dependent lookup
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您真的包含
吗?它是正确的axf.h
吗(你的系统上必须发生一些非常奇怪的事情才能保证它不正确)?您使用什么编译器版本?这个小程序可以在 VS2010 和 VS2008 上编译并正常运行:
它在您的系统上会发生什么情况?
Are you really including
<afx.h>
? Is it the rightaxf.h
(you'd have to have something pretty odd going on on your system for it to not be)? What compiler version are you using?This small program compiles and runs fine with VS2010 and VS2008:
What happens with it on your system?