无法用g ++编译头位/ stdc ++ 11

时间:2017-05-13 08:06:06

标签: c++11 g++

使用g++ file.cpp -std=c++11

在Windows上编译以下程序
#include<bits/stdc++.h>
using namespace std;

int main() {
    int x = 0;
    cout << x;
    return 0;
}

给出了一个错误,您可以在下面的链接中看到(由于stackoverflow的与文本约束相比代码太多而无法在此处发布错误,抱歉以这种方式发布!)

https://drive.google.com/file/d/0B4w9GgJk2CmjdGg0TjluWElNRTQ/view

In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\postypes.h:40:0,
                 from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\iosfwd:40,
                 from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ios:38,
                 from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\istream:38,
                 from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\sstream:38,
                 from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\complex:45,
                 from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\ccomplex:38,
                 from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\mingw32\bits\stdc++.h:52,
                 from template.cpp:1:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:177:11: error: '::wcscat' has not been declared
   using ::wcscat;
           ^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:178:11: error: '::wcscmp' has not been declared
   using ::wcscmp;
...

任何指针哪里出错了? (使用gcc 5.3)

1 个答案:

答案 0 :(得分:1)

使用std = gnu ++ 11

g++ file.cpp -std=gnu++11