正如标题所示,我遇到了一个相当奇怪的问题。当我尝试编译示例源代码(使用 libotb)时,我不断收到标题中的错误。奇怪的是 #include <iostream>
存在于报告错误的所述源/ header 中。
另一方面,如果我从上述文件中提取代码并创建一个单独的源代码并使用 g++ <source_file>
编译它它有效,但如果我用 g++ -I<path_to_libotb_headers> <source_file>
编译我得到了同样的错误,尽管源文件不包含来自所述路径的任何内容。
如以下评论所述,这个问题发生在
#include <iostream>
int main
{
std::cerr << "Test";
return 0;
}
最佳答案
#include <ostream>
应该修复它。在 C++11 下,#include <iostream>
应该拉入所有<ostream>
,但在 C++11 之前,您必须单独执行 #include
关于c++ - 命名空间 ‘std’ 中的“ostream”未命名类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13471314/