D.5. Chapter 7

Chapter 7 has two exercises.

D.5.1. Exercise 1

Using one of the dynamic linking approaches you’ve learned in this chapter, create the following:

  1. A side module containing an Add function that accepts two integer parameters and returns the sum as an integer
  2. A main module that has a main() function that calls the side module’s Add function and displays the result to the console window of the browser’s developer tools
Solution for the side module

In your WebAssembly\ folder, create an Appendix D\D.5.1\source\ folder. In your new source\ folder, create an add.c file, and then open it with your favorite editor.

Place the header file for Emscripten and the Add function shown in the following snippet in the add.c file:

#include ...

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.