Chapter 4. Reusing your existing C++ codebase
This chapter covers
- Adjusting a C++ codebase so that it can also be compiled by Emscripten
- Exporting WebAssembly functions so that they can be called by JavaScript
- Calling a WebAssembly function using Emscripten helper functions
- Passing strings and arrays to the WebAssembly module via the module’s memory
Typically, when people talk about the advantages of WebAssembly, it’s from the standpoint of performance. But WebAssembly brings another advantage to the table—code reuse. Rather than writing the same logic multiple times for each target environment (desktop, website, and others), WebAssembly lets you reuse the same code in multiple locations.
Imagine a scenario in which a company already has ...
Get WebAssembly in Action now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.