错误: strstream.h: 没有这样的文件或目录
error: strstream.h: No such file or directory
我正在尝试在Linux(Redhat)中运行旧的C++代码。我正在使用 gcc 版本 4.1.2。
我收到以下错误:
error: strstream.h: No such file or directory
/trnuser1/rmtrain/DevelopmentEnv/Generic/CoreObjects/GCVTransformationServices.cpp:41: error: âostrstreamâ was not declared in this scope
/trnuser1/rmtrain/DevelopmentEnv/Generic/CoreObjects/GCVTransformationServices.cpp:41: error: expected `;' before âstrDestXMLâ
/trnuser1/rmtrain/DevelopmentEnv/Generic/CoreObjects/GCVTransformationServices.cpp:62: error: âstrDestXMLâ was not declared in this scope
此代码在 gcc 版本 2.95 的 Solaris 下运行良好。错误指向的行包含以下语句:
ostrstream strDestXML;
我该如何解决这个问题?
你可以
#include <strstream>
(注意没有'.h'后缀)。但是,如果要将代码正确移植到新式C++,则应考虑将其更改为注释中建议的#include <sstream>
和std::ostringstream strDestXML;
。
标准C++标头没有扩展名。
#include <sstream>
标准类包含在std
命名空间中:
std::ostringstream strDestXML;
最后,strstream
被弃用;改用stringstream
- 这就是我在这里使用它的原因。
而且,只是关于 GCC 版本的注释 - 4.1.2 是旧的,无论如何 - 使用更新的东西。
此包含的现代名称是 <strstream>
。 (尽管它已正式弃用,但仍是必需的。 它定义的类在命名空间std
中,并且语义与经典的iostream略有不同,因此您以后可能需要进行一些修改。 (根据它的使用方式,更改为 <sstream>
,用 std::[io]stringstream
替换[io]strstream
可能是有意义的。
相关文章:
- .cpp和.h文件中的模板专用化声明
- 为什么两个不同的未命名名称空间可以共存于一个cpp文件中
- 文本文件中的单词链表
- CMake-按正确顺序将项目与C运行时对象文件链接
- 使用新行和不使用新行读取文件
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- 挂起和取消挂起一个文件DLL
- 如何确定我已使用非编码文件到达 EOF?
- 命名空间中具有.h和.cpp文件的类
- 如何使用ndk-build.cmd构建Android.so文件
- 从包含m行的文件中提取n行,必要时(惰性地)重复该文件
- 读取文件并输入到矢量中
- 在C++中查找文件
- c++库的公共头文件中应该包含什么
- 用c++从输入文件中读取另一行
- Cppcheck生成xml转储文件
- 读取文件的最后一行并输入到链接列表时出错
- 无法编译 rtmidi 测试 cmidiin.cpp 文件, 非法指令
- 如何将内容数组写入文本文件?
- 错误: strstream.h: 没有这样的文件或目录