我正在尝试在 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++ - 错误 : strstream. h:没有那个文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11153152/