Converting WASM into C
Learn how to convert WASM into C using the wasm2c command.
We'll cover the following...
We'll cover the following...
WABT has a wasm2c converter that converts WASM into C source code and a header.
Let’s create a simple.wat file:
Add the following contents to simple.wat:
wat here defines a uanswer function that adds 22 and 20 to give 42 as the answer. Let's create a WebAssembly binary using wat2wasm:
This generates the simple.wasm binary. Now, convert the binary into C code using wasm2c:
This generates simple.c and simple.h.
Note: Both
simple.candsimple.hmight look huge. Remember this is an autogenerated file and it includes all the ...