我正在使用clang 3.4和最新版本的emscripten.
如果我尝试使用C++ 14编译Hello World
emcc main.cpp -std=c++1y -o test.html
Run Code Online (Sandbox Code Playgroud)
Emscripten是否适用于C++ 14?
错误:
In file included from main.cpp:1:
In file included from /usr/share/emscripten/system/include/libcxx/iostream:38:
In file included from /usr/share/emscripten/system/include/libcxx/ios:216:
In file included from /usr/share/emscripten/system/include/libcxx/__locale:15:
In file included from /usr/share/emscripten/system/include/libcxx/string:439:
In file included from /usr/share/emscripten/system/include/libcxx/algorithm:627:
In file included from /usr/share/emscripten/system/include/libcxx/memory:601:
/usr/share/emscripten/system/include/libcxx/__functional_base:72:10: error: constexpr function's return type 'auto' is not a literal type
auto operator()(_T1&& __t, _T2&& __u) const
^
In file included from main.cpp:1:
In file included from /usr/share/emscripten/system/include/libcxx/iostream:38:
In file included from /usr/share/emscripten/system/include/libcxx/ios:216:
In file included from /usr/share/emscripten/system/include/libcxx/__locale:18:
In file included from /usr/share/emscripten/system/include/libcxx/mutex:177:
/usr/share/emscripten/system/include/libcxx/functional:506:10: error: constexpr function's return type 'auto' is not a literal type
auto operator()(_T1&& __t, _T2&& __u) const
^
/usr/share/emscripten/system/include/libcxx/functional:531:10: error: constexpr function's return type 'auto' is not a literal type
auto operator()(_T1&& __t, _T2&& __u) const
^
/usr/share/emscripten/system/include/libcxx/functional:556:10: error: constexpr function's return type 'auto' is not a literal type
auto operator()(_T1&& __t, _T2&& __u) const
^
/usr/share/emscripten/system/include/libcxx/functional:581:10: error: constexpr function's return type 'auto' is not a literal type
auto operator()(_T1&& __t, _T2&& __u) const
^
/usr/share/emscripten/system/include/libcxx/functional:606:10: error: constexpr function's return type 'auto' is not a literal type
auto operator()(_T1&& __t, _T2&& __u) const
^
/usr/share/emscripten/system/include/libcxx/functional:631:10: error: constexpr function's return type 'auto' is not a literal type
auto operator()(_Tp&& __x) const
^
/usr/share/emscripten/system/include/libcxx/functional:656:10: error: constexpr function's return type 'auto' is not a literal type
auto operator()(_T1&& __t, _T2&& __u) const
^
/usr/share/emscripten/system/include/libcxx/functional:681:10: error: constexpr function's return type 'auto' is not a literal type
auto operator()(_T1&& __t, _T2&& __u) const
^
/usr/share/emscripten/system/include/libcxx/functional:706:10: error: constexpr function's return type 'auto' is not a literal type
auto operator()(_T1&& __t, _T2&& __u) const
^
/usr/share/emscripten/system/include/libcxx/functional:733:10: error: constexpr function's return type 'auto' is not a literal type
auto operator()(_T1&& __t, _T2&& __u) const
^
/usr/share/emscripten/system/include/libcxx/functional:758:10: error: constexpr function's return type 'auto' is not a literal type
auto operator()(_T1&& __t, _T2&& __u) const
^
/usr/share/emscripten/system/include/libcxx/functional:783:10: error: constexpr function's return type 'auto' is not a literal type
auto operator()(_T1&& __t, _T2&& __u) const
^
/usr/share/emscripten/system/include/libcxx/functional:808:10: error: constexpr function's return type 'auto' is not a literal type
auto operator()(_T1&& __t, _T2&& __u) const
^
/usr/share/emscripten/system/include/libcxx/functional:833:10: error: constexpr function's return type 'auto' is not a literal type
auto operator()(_Tp&& __x) const
^
/usr/share/emscripten/system/include/libcxx/functional:858:10: error: constexpr function's return type 'auto' is not a literal type
auto operator()(_T1&& __t, _T2&& __u) const
^
/usr/share/emscripten/system/include/libcxx/functional:883:10: error: constexpr function's return type 'auto' is not a literal type
auto operator()(_T1&& __t, _T2&& __u) const
^
/usr/share/emscripten/system/include/libcxx/functional:908:10: error: constexpr function's return type 'auto' is not a literal type
auto operator()(_T1&& __t, _T2&& __u) const
^
/usr/share/emscripten/system/include/libcxx/functional:929:10: error: constexpr function's return type 'auto' is not a literal type
auto operator()(_Tp&& __x) const
^
19 errors generated.
ERROR root: compiler frontend failed to generate LLVM bitcode, halting
Run Code Online (Sandbox Code Playgroud)
更新:从版本 1.28 开始 Emscripten 使用 Clang 3.4,因此该版本中提供了 C++14 功能!
Emscripten 的 LLVM + Clang 实现 Fastcomp 目前基于 Clang 3.3(Emscripten 版本 1.26)。所以答案是否定的,Emscripten 目前不适用于 C++14。