C code for WebAssembly

Before we get to the C code we'll use for our WebAssembly module, let's try an experiment. Open the CLI in the /chapter-05-create-load-module folder, and try running this command:

emcc with-glue.c -Os -s WASM=1 -s USE_SDL=2 -s SIDE_MODULE=1 -s BINARYEN_ASYNC_COMPILATION=0 -o try-with-glue.wasm

You should see a try-with-glue.wasm file appear in VS Code's file explorer panel after the compilation is complete. Right-click on the file and select Show WebAssembly. The beginning of the corresponding Wat representation should resemble the following code:

(module  (type $t0 (func (param i32)))  (type $t1 (func (param i32 i32 i32 i32 i32) (result i32)))  (type $t2 (func (param i32) (result i32)))  (type $t3 (func)) (type $t4 (func ...

Get Learn WebAssembly 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.