源码 
#include <strstream> 
#include <iostream> 
using namespace std; 
int main() 

strstream* s = new strstream(); 
cin>> s ; 
cout << "test is " << s << endl; 
return 0; 

编译 
gcc -o test test.cpp 
报错 
C:\Dev-Cpp\include\c++\3.4.2\backward\backward_warning.h #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.

我看了别人的代码也是这么用的,但怎么就不报错吗?是编译器选项的问题吗(不是说加上-Wno-deprecated)?

答案1
因为 strstream 是非标准的,在C++标准制定之前曾经被使用过,现在新版本的编译器一般已经不再提供对它的支持了。应该使用 stringstream,对应的头文件为<sstream>。

答案2
strstream已经被stringstream取代,在sstream头文件中定义..

答案3
应该使用stringstream,放弃strstream

如果使用的话,还有报错。
报错与警告的解决方案:
[html] view plaincopyprint?
  1. set(CMAKE_CXX_FLAGS "-std=c++0x -Wno-deprecated")

就是在CXX_FLAGS中添加-std=c++0x 以及 -Wno-deprecated这两个选项

这两个选项的意思:c++0x是新的C++意思。而-Wno-deprecated是表示 no-deprecated这类警告忽略。

转载于:https://blog.51cto.com/ohyeahbbs/1174825

gcc下strstream使用时报错相关推荐

  1. win7系统下 安装anaconda时报错“failed to create menus”的解决方案

    本人还是win7,看到anaconda出了新版本,适配python3.9的.下载安装,出现了"Failed to creat menus",折腾了好几次依然如故.即使下载安装了迷你 ...

  2. 安装oracle gcc版本,安装cx_Oracle时报错:error: command 'gcc' failed with exit status 1

    安装cx_Oracle时报错:error: command 'gcc' failed with exit status 1 发布时间:2020-06-19 21:27:36 来源:51CTO 阅读:1 ...

  3. windows下安装mongodb时报错verify that you have sufficient privileges to start system services解决方法

    安装mongodb时出现的情况 系统:win7 提示: service 'mongodb server' failed to start.verify that you have sufficient ...

  4. Mac下添加Hibernate时报错Unsupported major.minor version

    2019独角兽企业重金招聘Python工程师标准>>> 出现这个错误是因为编译和运行项目的环境不一致造成的,比如编译时使用的是1.8的jdk,而运行时使用的是1.7的jre,就会报这 ...

  5. python特别是anaconda环境下安装库时报错需要Microsoft Visual C++ 14.0 or greater is required的终极解决方案

    网上所有方法我都尝试过,问题持续了好久,最终一个链接解决所有问题,这个方案目前全CSDN都没有. Installing the development version of scikit-learn ...

  6. win8(64位)下memcache安装时报错“ failed to install service or service already installed”

    环境: win8(64位)系统 错误提示: failed to install service or service already installed 解决办法: 1.找到cmd.exe文件(c:\ ...

  7. Windows下启动Apache报错:ServerRoot must be a valid directory

    在Windows环境下启动 Apache 时报错: httpd.exe: Syntax error on line 39 of D:\WebServer\Apache24\conf\httpd.con ...

  8. 关于启动nginx时报错:error while loading shared libraries: libpcre.so.1

    今天配置好nginx后在sbin目录下执行 ./nginx时报错如下: error while loading shared libraries: libpcre.so.1: cannot open ...

  9. Linux下通过 rm -f 删除大量文件时报错:Argument list too long

    Linux删除nagios的大量性能文件时报错 -bash: /bin/rm: Argument list too long 如下图所示: 问题原因 如?待删除文件中包含的小文件数量过多,通常是由于受 ...

最新文章

  1. Linux之链接命令
  2. 【持续更新】C++中string类使用总结
  3. jQuery中attr和prop方法的区别
  4. golang浮点型及使用细节
  5. python学习笔记(十二)标准库os
  6. just found out why the group by does not work for my app, but work for SCN exercise
  7. [Android学习笔记]使用ListView
  8. HDU 1964 Pipes
  9. python怎么使用预训练的模型_Keras使用ImageNet上预训练的模型方式
  10. 高精地图中地面标识识别技术历程与实践
  11. JavaScript中通过点击单选框动态显示和隐藏组件
  12. 项目汇报模板—再也不怕撕逼了
  13. java脚手架_Java代码重构
  14. Java工作小组组名,起组名和口号大全
  15. laravel中guard是什么
  16. 1553B通信项目开发笔记(四)bu61580程序编写,实现回环之RT端
  17. ajax 数据接收,前端数据获取之Ajax篇
  18. 两个相同字组成的汉字 - 中国汉字的奇妙(三)
  19. 华为云大数据BI 为中小型企业智慧运营保驾护航
  20. lnk306dn引脚功能_LNK306DN

热门文章

  1. 特斯拉首个中国工厂落户上海临港
  2. 26所高校联合建议:尽快设置人工智能本科专业
  3. 欧空局2018机器学习系列课程发布:从概念到实践(视频+PPT)
  4. MIT自动驾驶导航系统,不看地图也能穿梭乡间野路
  5. 2018年IEEE Fellow名单:32位中国学者入选,清华成最大赢家
  6. 下载安装 Ubuntu 19.04 “Disco Dingo”
  7. H2最完整的资料下载地址:
  8. ArchLinux借助Winetricks-zh安裝WineQQ8.1
  9. Struts提供我们方便地将客户端上传的文件处理
  10. 使用Typescript开发(二)