emscripten-core / emscripten-core/emscripten
Create Wasm globals from C code?
Open
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
I would like to define WebAssembly `global`s in C code, something like
```c
int __attribute__((wasm_global)) myGlobal = 5;
```
that would then emit a
```wast
(global $myGlobal i32 (i32.const 5))
```
into the build. Setting and reading the variable would then emit `global.get` and `global.set`, and taking an address `&myGlobal` would then be forbidden at compile time. Is there a way to do that today, or would it be possible to add?
Contributor guide
Assessment
This issue has not been assessed yet.