我正在尝试在Linux系统上编译一些代码。使用命令mpic++ -std=c++11
时总会出现奇怪的错误。名为“HW.cpp”的文件中的代码如下:
#include<mpi.h>
#include<iostream>
using namespace std;
int main(int argc, char** argv){
int myid,numprocs;
int namelen;
char processor_name[MPI_MAX_PROCESSOR_NAME];
MPI_Init(&argc,&argv);
MPI_Comm_rank(MPI_COMM_WORLD,&myid);
MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
MPI_Get_processor_name(processor_name,&namelen);
cout<<"Hello World! Process "<<myid<<" of "<<numprocs<<endl;
MPI_Finalize();
}
当我使用命令mpic++ HW.cpp
时,每件事都很好,但是当我这样做时mpic++ -std=c++11 HW.cpp
,我会收到如下错误:
In file included from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ext/alloc_traits.h(36),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/basic_string.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/string(52),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/locale_classes.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/ios_base.h(41),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ios(42),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ostream(38),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/iostream(39),
from HM.cpp(2):
/WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/alloc_traits.h(251): error: expected a ">"
= typename __construct_helper<_Tp, _Args...>::type;
^
In file included from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ext/alloc_traits.h(36),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/basic_string.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/string(52),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/locale_classes.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/ios_base.h(41),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ios(42),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ostream(38),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/iostream(39),
from HM.cpp(2):
detected during instantiation of type "std::allocator_traits<_Alloc>::__has_construct<_Tp, _Args...>" at line 254
In file included from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ext/alloc_traits.h(36),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/basic_string.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/string(52),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/locale_classes.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/ios_base.h(41),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ios(42),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ostream(38),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/iostream(39),
from HM.cpp(2):
In file included from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ext/alloc_traits.h(36),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/basic_string.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/string(52),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/locale_classes.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/ios_base.h(41),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ios(42),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ostream(38),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/iostream(39),
from HM.cpp(2):
/WORK/app/gcc/5.2.0/include/c++/5.2.0/type_traits(133): error: not a class or struct name
: public _B1
^
In file included from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ext/alloc_traits.h(36),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/basic_string.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/string(52),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/locale_classes.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/ios_base.h(41),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ios(42),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ostream(38),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/iostream(39),
from HM.cpp(2):
detected during:
In file included from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ext/alloc_traits.h(36),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/basic_string.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/string(52),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/locale_classes.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/ios_base.h(41),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ios(42),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ostream(38),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/iostream(39),
from HM.cpp(2):
instantiation of class "std::__and_<_B1> [with _B1=<error-type>]" at line 2108
In file included from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ext/alloc_traits.h(36),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/basic_string.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/string(52),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/locale_classes.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/ios_base.h(41),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ios(42),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ostream(38),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/iostream(39),
from HM.cpp(2):
instantiation of type "std::_Require<<error-type>>" at line 254 of "/WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/alloc_traits.h"
In file included from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ext/alloc_traits.h(36),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/basic_string.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/string(52),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/locale_classes.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/ios_base.h(41),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ios(42),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ostream(38),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/iostream(39),
from HM.cpp(2):
In file included from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ext/alloc_traits.h(36),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/basic_string.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/string(52),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/locale_classes.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/ios_base.h(41),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ios(42),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ostream(38),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/iostream(39),
from HM.cpp(2):
/WORK/app/gcc/5.2.0/include/c++/5.2.0/type_traits(2108): error: class "std::__and_<<error-type>>" has no member "value"
using _Require = typename enable_if<__and_<_Cond...>::value>::type;
^
In file included from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ext/alloc_traits.h(36),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/basic_string.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/string(52),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/locale_classes.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/ios_base.h(41),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ios(42),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ostream(38),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/iostream(39),
from HM.cpp(2):
detected during instantiation of type "std::_Require<<error-type>>" at line 254 of "/WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/alloc_traits.h"
In file included from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ext/alloc_traits.h(36),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/basic_string.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/string(52),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/locale_classes.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/ios_base.h(41),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ios(42),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ostream(38),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/iostream(39),
from HM.cpp(2):
In file included from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ext/alloc_traits.h(36),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/basic_string.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/string(52),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/locale_classes.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/ios_base.h(41),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ios(42),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ostream(38),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/iostream(39),
from HM.cpp(2):
/WORK/app/gcc/5.2.0/include/c++/5.2.0/type_traits(2108): error: class "std::enable_if<<error-constant>, void>" has no member "type"
using _Require = typename enable_if<__and_<_Cond...>::value>::type;
^
In file included from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ext/alloc_traits.h(36),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/basic_string.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/string(52),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/locale_classes.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/ios_base.h(41),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ios(42),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ostream(38),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/iostream(39),
from HM.cpp(2):
detected during instantiation of type "std::_Require<<error-type>>" at line 254 of "/WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/alloc_traits.h"
In file included from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ext/alloc_traits.h(36),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/basic_string.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/string(52),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/locale_classes.h(40),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/ios_base.h(41),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ios(42),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/ostream(38),
from /WORK/app/gcc/5.2.0/include/c++/5.2.0/iostream(39),
from HM.cpp(2):
/WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/stl_iterator_base_types.h(154): error: class "std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>" has no member "iterator_category"
typedef typename _Iterator::iterator_category iterator_category;
^
detected during:
instantiation of class "std::__iterator_traits<_Iterator, void> [with _Iterator=std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>]" at line 163
instantiation of class "std::iterator_traits<_Iterator> [with _Iterator=std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>]" at line 4865 of "/WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/basic_string.h"
instantiation of "std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Alloc> &&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc> &&) [with _CharT=char, _Traits=std::char_traits<char>, _Alloc=std::allocator<char>]" at line 343 of "/WORK/app/gcc/5.2.0/include/c++/5.2.0/system_error"
/WORK/app/gcc/5.2.0/include/c++/5.2.0/type_traits(1492): error: class "std::__is_convertible_helper<<error-type>, std::input_iterator_tag, false>" has no member class "type"
: public __is_convertible_helper<_From, _To>::type
^
detected during:
instantiation of class "std::is_convertible<_From, _To> [with _From=<error-type>, _To=std::input_iterator_tag]" at line 4865 of "/WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/basic_string.h"
instantiation of "std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Alloc> &&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc> &&) [with _CharT=char, _Traits=std::char_traits<char>, _Alloc=std::allocator<char>]" at line 343 of "/WORK/app/gcc/5.2.0/include/c++/5.2.0/system_error"
/WORK/app/gcc/5.2.0/include/c++/5.2.0/type_traits(1492): error: not a class or struct name
: public __is_convertible_helper<_From, _To>::type
^
detected during:
instantiation of class "std::is_convertible<_From, _To> [with _From=<error-type>, _To=std::input_iterator_tag]" at line 4865 of "/WORK/app/gcc/5.2.0/include/c++/5.2.0/bits/basic_string.h"
instantiation of "std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Alloc> &&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc> &&) [with _CharT=char, _Traits=std::char_traits<char>, _Alloc=std::allocator<char>]" at line 343 of "/WORK/app/gcc/5.2.0/include/c++/5.2.0/system_error"
compilation aborted for HM.cpp (code 2)
我对这些错误感到困惑。