emscripten icon indicating copy to clipboard operation
emscripten copied to clipboard

When exporting functions from a C++ module, it is necessary to specify EXPORTED_FUNCTIONS for each function.

Open xengine-qyt opened this issue 1 year ago • 3 comments

Is there any other way to automatically export all functions from a file? Or specify a macro in front of the functions to be exported?

xengine-qyt avatar Sep 23 '24 09:09 xengine-qyt

No, there is no mechanism for that I'm afraid. I'm not sure I'd want to add one either. What would your use case be fore exports so many functions? Normally folks either exports small fixed set of functions, or use something like embind to export a more rich set. What is your use case?

sbc100 avatar Sep 23 '24 17:09 sbc100

No, there is no mechanism for that I'm afraid. I'm not sure I'd want to add one either. What would your use case be fore exports so many functions? Normally folks either exports small fixed set of functions, or use something like embind to export a more rich set. What is your use case?

I have a cross-platform framework module library, and the export functions are already in place. There are many functions to export, so I thought this approach might be more convenient. Specifying them one by one is very time-consuming... So I wanted to ask if there is a more convenient mechanism.

xengine-qyt avatar Sep 25 '24 01:09 xengine-qyt

The reason I think we don't have that mechism is that in general raw C/C++ are not very useful when exposed to JavaScript. Do you intend to try to call these function directly from JS? Normally you would want to do something like embind to make your library accessible to JS. Calling wasm functions directly from JS or using ccall (for example) is a fairly rare case I believe.

sbc100 avatar Sep 25 '24 02:09 sbc100