Ubuntu 16.04 LTS(サーバー)でコンパイル中に問題が発生しています。-std=c++11
ビットを含めなくても問題なくコンパイルできます。Clangのバージョンは3.8です。
>cat foo.cpp
#include <string>
#include <iostream>
using namespace std;
int main(int argc,char** argv) {
string s(argv[0]);
cout << s << endl;
}
>clang++ -std=c++11 -stdlib=libc++ foo.cpp
In file included from foo.cpp:1:
/usr/include/c++/v1/string:1938:44: error: 'basic_string<_CharT, _Traits, _Allocator>' is missing exception specification
'noexcept(is_nothrow_copy_constructible<allocator_type>::value)'
basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a)
^
/usr/include/c++/v1/string:1326:40: note: previous declaration is here
_LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a)
^
1 error generated.
標準ライブラリのusing とそのヘッダーlibc++-dev
をclang++
使用してビルドできるはずの(正しい)期待でubuntu 16.04にインストールしましたlibc++
。
それはそうすべきですが、あなたが遭遇したDebianバグ#808086のstd=c++11
ために(またはそれ以降の標準)の存在下ではそうなりません。
clang++
C ++ 11標準以降でコンパイルする場合は、ubuntuがこれを修正するまでlibc++
、libstdc++
代わりに(GNU C ++標準ライブラリ)を使用する必要があります。これはデフォルトの動作です。
clang++ -std=c++11 foo.cpp
または:
clang++ -std=c++11 -stdlib=libstdc++ foo.cpp
動作します。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加