c++ - 命名空间 ‘std’ 中的“ostream”未命名类型

标签 c++ linux gcc g++

正如标题所示,我遇到了一个相当奇怪的问题。当我尝试编译示例源代码(使用 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/

相关文章:

c++ - 使用迭代器从字符串中删除特殊字符

c++ - 如何将类型别名设置为 "a pointer to an array of const int"?

C++在学生列表中搜索和排序

c++ - 比较 2 个 c++ std::lists 的最快方法,在每次迭代中改变

linux - apache日志中没有IP地址

linux - 变量没有传递到远程机器

linux - 通过用户空间 I/O (UIO) Linux 驱动程序与 QEMU edu 设备连接

windows - 在 Windows 上安装 Rust

c - 为什么 -O3 GCC Optimization 没有内联这个函数?

c - 在64位系统中复制unsigned int 2次和unsigned long 1次有什么区别?