Thanks, Floh.  it works when the function is defined.
Actually, my function is an external function declaration, like
extern "C" void foo();

It doesn't work even I declare like this:
extern "C" void EMSCRIPTEN_KEEPALIVE foo().

Do you have any idea for this situation?

Floh <flo...@gmail.com> 于2019年5月2日周四 下午10:13写道:

> Have a look at EMSCRIPTEN_KEEPALIVE:
> https://emscripten.org/docs/api_reference/emscripten.h.html#c.EMSCRIPTEN_KEEPALIVE,
> this prevents a C/C++ function from being removed even when it isn't
> referenced by other C/C++ code (normally this is used to call C functions
> from the JS side).
>
> On Thursday, 2 May 2019 08:16:43 UTC+2, Duan Bing wrote:
>>
>> I declare an external function in C source file, but never used by the
>> code, then compile it to wasm by EMCC.   there is no doubt the external
>> function will be eliminated by the compiler.
>>
>> Is there any approach to keep this external function and then be compiled
>> to an import function in wasm?
>>
>> The motivation to remain the external function is that I want to insert
>> some wasm code in the wasm file after it's generated.
>>
>> Thanks all!
>>
> --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to emscripten-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to