emscripten: How can I solve UnboundTypeError

一世执手 提交于 2019-11-30 20:45:25

Embind doesn't support pointers to primitive types. "Pi" means to "pointer to integer."

If you will always know the size of the array in advance, you could try passing the array as a const reference. e.g.

std::vector<int> intArrayToVector(const int (&input)[100])

Or you can cheat and use an integer parameter for the pointer and use reinterpret_cast to treat it as a pointer. e.g.

std::vector<int> intArrayToVector(uintptr_t input, size_t len) {
    const int* ptr = reinterpret_cast<int*>(input);
    ....
}

Or you can use the cwrap API which does support pointers to primitive types.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!