C++ in WebAssembly

C++ support for WebAssembly is handled by the C language support. And C language support is currently excellent.

However, specific C++ tools are maturing quickly. For example, Cheerp targets compiling C++ to WebAssembly with generated JavaScript interop.

Read the C language guide for examples and more coverage of the WASI SDK, Clang, LLVM, and Emscripten


For the most part, C++ support comes via C support. Both Emscripten and the C WASI SDK provide support for C++. Recent versions of LLVM and Clang support WebAssembly out of the box.

For this reason, it should be possible to compile C++ code both for browser targets and WASI targets. One thing to be aware of with C++, though, is that exception handling is not yet supported.

Pros and Cons

Things we like:

  • Because C is so well supported, C++ is among the better supported WebAssembly languages
  • It is great that common compilers have added support
  • We believe C++-centered tooling for WebAssembly is on the rise

We’re neutral about:

  • Setup is not easy, but it is doable

Things we’re not big fans of:

  • Features like exception handling are sorely missed


See the example on the C page.

Learn More

Here are some great resources: