Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emscripten and C++14

I am using clang 3.4 and the newest version of emscripten.

If I try to compile Hello World with C++14

emcc main.cpp -std=c++1y -o test.html

Does Emscripten work with C++14?

Error:

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
like image 859
Maik Klein Avatar asked Oct 20 '22 01:10

Maik Klein


1 Answers

UPDATE: Starting from version 1.28 Emscripten uses Clang 3.4, so C++14 features are available in this version!

Emscripten's LLVM + Clang implementation Fastcomp is based on Clang 3.3 at the moment (Emscripten version 1.26). So the answer is no, Emscripten doesn't work with C++14 for now.

like image 147
Nikolay Vorobyov Avatar answered Oct 24 '22 00:10

Nikolay Vorobyov