I would like to port a C library. There is a really short tutorial about it here: Interacting with code
I need to create a struct using javascript, and return a pointer to it. I looked into the libraries, which are already ported. My code looks like this:
var ptr = _malloc({{{ C_STRUCTS.MyStruct.__size__ }}});
{{{ makeSetValue('ptr', C_STRUCTS.MyStruct.attr, '0', 'i8') }}};
It does not work, because emscripten does not know about MyStruct
.
My library definition is added to the project using --js-library
But I don't know, how to add a struct definition (struct_info.json
)
In the C code, I have:
struct MyStruct {
int8_t attr;
//...
}