Skip to content Skip to sidebar Skip to footer

Accessing Struct Fields From Emscripten

Given the following code: typedef struct { int foo; } Bar; Bar test() { Bar result = { .foo = 2 }; return result; } and assuming that test() can be accessed from JavaScript, ho

Solution 1:

One workaround is doing things as in java:

Bar createBar(int foo) {
  Bar result = { .foo = foo };
  return result;
}

int getFoo(Bar in) { return in.foo; }

Ugly, adds boilerplate, and requires more stuff be exported, but it works.


Post a Comment for "Accessing Struct Fields From Emscripten"