我正在尝试在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/

10-14 20:54
查看更多