In wit-bindgen, a lot of the generators have a wasm_type
function which converts WasmType
to the destination language type, but it doesnt differentiate singed/unsigned. Why is that, many languages differentiate between signed and unsigned integers ? THe C example for the numbers test produces
int32_t __wasm_import_test_numbers_test_roundtrip_u32(int32_t);
When I would have expected to see uint32_t
as this is the test for an unsigned 32bit int.
That's the raw untyped import, the typed import will have uint32_t
I see. The raw imports must have native wasm types because of something that means you can't rely on the target language wasm compiler to do that conversion?
Sort of, certainly for aggregates but we could use unsigned types there in that example. Because a wrapper is always generated it's easier to always use i32 and then convert for the real function. At runtime it shouldn't matter since it all goes away anyway
Thanks, Not tackled aggregrates yet but I see that might be more complicated depending on how the target language tackles the interop. And yes agree it would probably get inlined away during optimisation.
Scott Waye has marked this topic as resolved.
Last updated: Nov 22 2024 at 16:03 UTC