Update Cookbook.md

extensions
Volodymyr Shymanskyy 3 years ago committed by GitHub
parent d931d669d9
commit 011e04bcfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -52,40 +52,35 @@ Result: 3
The easiest way to start is to use [Wasienv](https://github.com/wasienv/wasienv). The easiest way to start is to use [Wasienv](https://github.com/wasienv/wasienv).
Create `hello.c`: ### C/C++ WASI app
```c
#include <stdio.h>
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
Create `hello.cpp`: Create `hello.cpp`:
```cpp ```cpp
#include <iostream> #include <iostream>
int main() {
int main() std::cout << "Hello, world!" << std::endl;
{
std::cout << "Hello World!" << std::endl;
return 0; return 0;
} }
``` ```
Or `hello.c`:
```c
#include <stdio.h>
int main() {
printf("Hello, %s!\n", "world");
return 0;
}
```
```sh ```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 $ wasm3 hello.wasm
Hello World! Hello World!
``` ```
Limitations:
- `setjmp/longjmp` and `C++ exceptions` are not available
- no support for `threads` and `atomics`
- no support for `dynamic libraries`

Loading…
Cancel
Save