所以我正在尝试从 ArrayBuffer 创建一个 WebAssembly 模块。
C代码:
#include <stdio.h>
int main() {
printf("hello, world!\n");
return 0;
}
我像这样编译它:
$ emcc -O2 hello.c -s WASM=1 -o hello.html
我启动了一个本地 http 服务器。我尝试像这样在我的浏览器中加载它:
fetch('hello.wasm')
.then(res => res.arrayBuffer())
.then(buff => WebAssembly.Module(buff));
我收到以下错误:
Uncaught (in promise) RangeError: WebAssembly.Module(): Wasm 编译在此上下文中超出了 fetch.then.then.buff (:1:77) 处提供的参数的内部限制
我不知道如何解决这个错误,也无法通过网络搜索找到任何东西。
任何帮助表示赞赏
谢谢!