On Thu, Nov 27, 2025 at 8:59 AM John Dallman <[email protected]> wrote:
> On Wed, Nov 26, 2025 at 9:06 PM 'Sam Clegg' via emscripten-discuss < > [email protected]> wrote: > > > Function signatures need to be an exact match at the Wasm level. At the > wasm level > > signatures are made of only the core i32, i64, f32, f64 types, so its > likely the many different > > C signatures have the same Wasm signature. > > OK, I presume pointers are i32 or i64, according to if you're building for > 32-bit or 64-bit Wasm? > Yes, exactly. > > > As long as you are casting the void* pointer back to the correct > function type before calling them > > you should have no issues. > > I've found my mistake now. I have a lot of changes to make, though. > > Thanks, > > John > On Wed, Nov 26, 2025 at 9:06 PM 'Sam Clegg' via emscripten-discuss < > [email protected]> wrote: > >> >> >> On Wed, Nov 26, 2025 at 3:23 AM John Dallman <[email protected]> >> wrote: >> >>> I have a lot of code that stores pointers to functions as void* and then >>> casts them back to the "correct" type. This is part of a LISP interpreter >>> that is embedded in my product's test harness, and used to write test >>> scripts. >>> >>> This works in conventional C, but I'm having trouble with it in >>> WebAssembly. I've found that functions with and without argument lists >>> don't match, which is quite reasonable, but I'm having trouble getting a >>> fix to work. >>> >>> Just how identical do the function signatures have to be? >>> >>> - Character-for-character identical? >>> - Identical types with different names are OK? >>> - Static and non-static functions with otherwise >>> identical signatures are OK? >>> - Something else? >>> >>> >> Function signatures need to be an exact match at the Wasm level. At the >> wasm level signatures are made of only the core i32, i64, f32, f64 types, >> so its likely the many different C signatures have the same Wasm signature. >> >> As long as you are casting the void* pointer back to the correct function >> type before calling them you should have no issues. >> >> If you are trying to call a function with too many, or too few arguments >> that does not work. >> >> We do have a setting that can help if you really need to do >> this: EMULATE_FUNCTION_POINTER_CASTS. See >> https://emscripten.org/docs/tools_reference/settings_reference.html#emulate-function-pointer-casts >> for more info on this. This setting is used by some projects (notably >> Python and Glib) which depend on being able to call via mismatched >> signatures. You should be aware that this setting does come with a >> runtime cost though. >> >> cheer, >> sam >> >> -- >> 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 [email protected]. >> To view this discussion visit >> https://groups.google.com/d/msgid/emscripten-discuss/CAL_va28ocNLCKKvbomaW2Ci5Asf70uyqis0vKADYBW1XDe0x1A%40mail.gmail.com >> <https://groups.google.com/d/msgid/emscripten-discuss/CAL_va28ocNLCKKvbomaW2Ci5Asf70uyqis0vKADYBW1XDe0x1A%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- > 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 [email protected]. > To view this discussion visit > https://groups.google.com/d/msgid/emscripten-discuss/CAH1xqgmsPcWmJk3TTjfe-S6gj%3Dyt4EwVu5KZTyfFgvgnP6Viag%40mail.gmail.com > <https://groups.google.com/d/msgid/emscripten-discuss/CAH1xqgmsPcWmJk3TTjfe-S6gj%3Dyt4EwVu5KZTyfFgvgnP6Viag%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- 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 [email protected]. To view this discussion visit https://groups.google.com/d/msgid/emscripten-discuss/CAL_va2-DP1v_JY2Hm6-ym6XCmATWLqumv%2B%2BYR%2Bj%2BtsjNOnicEg%40mail.gmail.com.
