emscripten-core / emscripten-core/emscripten
‘Implement a C API in JavaScript’ ,the implement must be in window global environment?
Open
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
First, In C code, define the interface
`extern "C"{
extern void test(int a,int b);
int callAdd ()
{
test(2,3);
}
}`
Second, in library.js ,implement the interface in JavaScript:
`
test__proxy:'async',
test__sig:'vii;,
test:function(a,b)
{
console.log(a+", and"+b);
JS_Test();
}
`
Then , compile , `emcc test.cpp -o test.js --js-library library.js`
Last in html/js , i call the function 'callAdd' , so my question : the `JS_Test()` must in window global environment to implement it ?
Contributor guide
Assessment
This issue has not been assessed yet.