From 011e04bcfa8d981ffb800d182d826072803bfa54 Mon Sep 17 00:00:00 2001 From: Volodymyr Shymanskyy Date: Fri, 30 Apr 2021 13:57:16 +0300 Subject: [PATCH] Update Cookbook.md --- docs/Cookbook.md | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/docs/Cookbook.md b/docs/Cookbook.md index cb56a2a..df4e190 100644 --- a/docs/Cookbook.md +++ b/docs/Cookbook.md @@ -52,40 +52,35 @@ Result: 3 The easiest way to start is to use [Wasienv](https://github.com/wasienv/wasienv). -Create `hello.c`: -```c -#include - -int main() -{ - printf("Hello, %s!\n", "world"); - return 0; -} -``` - -```sh -$ wasicc -O3 -Wl,--stack-first hello.c -o hello.wasm - -$ wasm3 hello.wasm -Hello, world! -``` - -### C++ WASI app +### C/C++ WASI app Create `hello.cpp`: ```cpp #include - -int main() -{ - std::cout << "Hello World!" << std::endl; +int main() { + std::cout << "Hello, world!" << std::endl; return 0; } ``` +Or `hello.c`: +```c +#include +int main() { + printf("Hello, %s!\n", "world"); + return 0; +} +``` + ```sh -$ wasic++ -O3 -Wl,--stack-first hello.cpp -o hello.wasm +$ wasic++ -O3 hello.cpp -o hello.wasm +$ wasicc -O3 hello.c -o hello.wasm $ wasm3 hello.wasm Hello World! ``` + +Limitations: +- `setjmp/longjmp` and `C++ exceptions` are not available +- no support for `threads` and `atomics` +- no support for `dynamic libraries`