Maison  >  Questions et réponses  >  le corps du texte

linux - g++编译,总是提示头文件fstream错误

代码很简单,但是总是提示fstream头文件有错误,操作系统是centos7 64位。

#include <fstream>
#include <iostream>
using namespace std;

int main()
{
    cout<<"hello,world"<<endl;
    return 0;
}

编译报如下错误:
[root@mystudy test]# g++ -o test test.cpp
In file included from /usr/include/c++/4.8.2/fstream:41:0,

             from test.cpp:1:

/usr/include/c++/4.8.2/cstdio:120:11: error: '::ets' has not been declared
using ::ets;

天蓬老师天蓬老师2713 Il y a quelques jours663

répondre à tous(3)je répondrai

  • 黄舟

    黄舟2017-04-17 17:10:18

    因为它就是有错误的啊。不知道什么时候被修改了。

    都说过多少遍了,不要随意使用 root 权限,你们不听。没事非要搬石头,这次砸自己脚了吧?

    最安全的建议:重装系统。
    (可能)省力一点的建议:重装 g++ 之类的包(可能需要先卸载再安装)

    répondre
    0
  • 巴扎黑

    巴扎黑2017-04-17 17:10:18

    同样的代码,在gcc v4.8.2下编译测试没有问题。
    看这里报错,应该是在cstdio这个文件的120行处的ets没有声明。
    看了下cstdio这个文件,这个地方应该是using ::gets;,所以你看看你的cstdio这个文件是否正常?里面是不是被修改了。

    répondre
    0
  • 黄舟

    黄舟2017-04-17 17:10:18

    重装build-essential即可。头文件挂了剩下的就不用写了。

    répondre
    0
  • Annulerrépondre