add a note on EXPORTED_FUNCTIONS mattering on the comple to JS stage #3759
This commit is contained in:
Родитель
f9def006b9
Коммит
ae02f340a1
|
@ -255,6 +255,11 @@ To make sure a C function remains available to be called from normal JavaScript,
|
||||||
|
|
||||||
./emcc -s EXPORTED_FUNCTIONS="['_main', '_my_func']" ...
|
./emcc -s EXPORTED_FUNCTIONS="['_main', '_my_func']" ...
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
`EXPORTED_FUNCTIONS` affects compilation to JavaScript. If you first compile to an object file,
|
||||||
|
then compile the object to JavaScript, you need that option on the second command.
|
||||||
|
|
||||||
If your function is used in other functions, LLVM may inline it and it will not appear as a unique function in the JavaScript. Prevent inlining by defining the function with :c:type:`EMSCRIPTEN_KEEPALIVE`: ::
|
If your function is used in other functions, LLVM may inline it and it will not appear as a unique function in the JavaScript. Prevent inlining by defining the function with :c:type:`EMSCRIPTEN_KEEPALIVE`: ::
|
||||||
|
|
||||||
void EMSCRIPTEN_KEEPALIVE yourCfunc() {..}
|
void EMSCRIPTEN_KEEPALIVE yourCfunc() {..}
|
||||||
|
|
|
@ -65,6 +65,13 @@ home directory::
|
||||||
|
|
||||||
./emcc tests/hello_function.cpp -o function.html -s EXPORTED_FUNCTIONS="['_int_sqrt']"
|
./emcc tests/hello_function.cpp -o function.html -s EXPORTED_FUNCTIONS="['_int_sqrt']"
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
`EXPORTED_FUNCTIONS` affects compilation to JavaScript. If you first compile to an object file,
|
||||||
|
then compile the object to JavaScript, you need that option on the second command. If you do
|
||||||
|
it all together as in the example here (source straight to JavaScript) then this just works,
|
||||||
|
of course.
|
||||||
|
|
||||||
After compiling, you can call this function with :js:func:`cwrap` using the
|
After compiling, you can call this function with :js:func:`cwrap` using the
|
||||||
following JavaScript::
|
following JavaScript::
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче