emscripten-core / emscripten-core/emscripten

‘Implement a C API in JavaScript’ ,the implement must be in window global environment?

Open
#17,242 1 comment 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.