Re:Show HN: How to compile C/C++ for WASM, pure Clang, no li...
by jstimpfle on Monday April 11, 2022 @03:35PM
(#30993643)
Pedantically, it might even be undefined behaviour (not sure, maybe a point of contention, similar to container_of macro). It's unlikely to cause problems, but the way you suggested is better (and can even be accompanied by a length field).
Thank you to the author though! It is a nice little example.
One thing that's bothering me about that code is the declaration of `memory` as an uint8_t when it's clearly being used for its address:
And then in a lot of places: Declaring `memory` as an array is much more idiomatic C, and generates the exact same assembly: And then I just tested it, and it seems to work exactly as one would expect from a plain C linker (so there's no WASM magic I can see). Am I missing something?