emscripten: How can I solve UnboundTypeError

前端 未结 1 1261
借酒劲吻你
借酒劲吻你 2021-01-02 16:25

I am trying to build with emscripten a program which uses std::vector and std::map and the compilation is successful. However, when I ran it on the web browser(firefox/chrom

1条回答
  •  [愿得一人]
    2021-01-02 16:40

    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 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 intArrayToVector(uintptr_t input, size_t len) {
        const int* ptr = reinterpret_cast(input);
        ....
    }
    

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

    0 讨论(0)
提交回复
热议问题