mardi 3 avril 2018

Can't compile Hello World with "-std=c++11"

there seems to be something wrong with my g++ compiler. It can't compile code with "-std=c++11" option on Ubuntu 16.04 with g++ 5.4.0.

So I write a really simple Hello World program :

//Hello.cpp
#include <iostream>

using namespace std;

int main(){
    cout<<"Hello World"<<endl;
}

If I compile it with g++ :

g++ Hello.cpp

it works fine.

But if I add "-std=c++11" :

g++ -std=c++11 Hello.cpp

g++ gives me tons of error message, more than 1000 lines.

Here is some of them:

In file included from /usr/include/c++/5/bits/stl_pair.h:59:0,
             from /usr/include/c++/5/bits/stl_algobase.h:64,
             from /usr/include/c++/5/bits/char_traits.h:39,
             from /usr/include/c++/5/ios:40,
             from /usr/include/c++/5/ostream:38,
             from /usr/include/c++/5/iostream:39,
             from Hello.cpp:1:
/usr/include/c++/5/bits/move.h:76:27: error: ‘remove_reference’ in namespace ‘std’ does not name a template type
 forward(typename std::remove_reference<_Tp>::type& __t) noexcept
                       ^
/usr/include/c++/5/bits/move.h:76:43: error: expected ‘,’ or ‘...’ before ‘<’ token
 forward(typename std::remove_reference<_Tp>::type& __t) noexcept
                                       ^
/usr/include/c++/5/bits/move.h: In function ‘constexpr _Tp&& std::forward(int)’:
/usr/include/c++/5/bits/move.h:77:33: error: ‘__t’ was not declared in this scope
 { return static_cast<_Tp&&>(__t); }
                             ^

Same code works fine on other computers.

Do you have any ideas?

Aucun commentaire:

Enregistrer un commentaire