emscripten-core/emscripten

bind failure with register_vector / "implicit instantiation of undefined template"

Open

#9,005 创建于 2019年7月16日

在 GitHub 查看
 (7 评论) (2 反应) (0 负责人)C++ (3,519 fork)batch import
embindhelp wantedwontfix

仓库指标

Star
 (27,361 star)
PR 合并指标
 (平均合并 19天 10小时) (30 天内合并 147 个 PR)

描述

Previously (emscripten-1.38.29), this code snippet worked and compiled without error:

std::vector<std::wstring> VectorAPI::createStringVector()
{
    return std::vector<std::wstring>();
}

EMSCRIPTEN_BINDINGS(VectorAPI)
{
    class_<VectorAPI>("VectorAPI")
        .class_function("createStringVector", &VectorAPI::createStringVector);
    register_vector<std::wstring>("vector<wstring>");
}

However, on the latest version, I get this instead:

In file included from src/api/VectorAPI.cpp:3:
In file included from src/api/VectorAPI.h:6:
/mnt/c/git/emsdk/upstream/emscripten/system/include/emscripten/bind.h:1423:13: error: implicit instantiation of undefined template 'emscripten::internal::RegisterClassMethod<unsigned long (std::__2::vector<std::__2::basic_string<wchar_t>, std::__2::allocator<std::__2::basic_string<wchar_t> > >::*)() const noexcept>'
            invoker::template invoke<ClassType, Policies...>(methodName, callable);
            ^
/mnt/c/git/emsdk/upstream/emscripten/system/include/emscripten/bind.h:1600:14: note: in instantiation of function template specialization 'emscripten::class_<std::__2::vector<std::__2::basic_string<wchar_t>, std::__2::allocator<std::__2::basic_string<wchar_t> > >, emscripten::internal::NoBaseClass>::function<emscripten::internal::DeduceArgumentsTag, unsigned long (std::__2::vector<std::__2::basic_string<wchar_t>, std::__2::allocator<std::__2::basic_string<wchar_t> > >::*)() const noexcept>' requested here
            .function("size", &VecType::size)
             ^
src/api/VectorAPI.cpp:26:5: note: in instantiation of function template specialization 'emscripten::register_vector<std::__2::basic_string<wchar_t> >' requested here
    register_vector<std::wstring>("vector<wstring>");
    ^
/mnt/c/git/emsdk/upstream/emscripten/system/include/emscripten/bind.h:1150:16: note: template is declared here
        struct RegisterClassMethod;
               ^
1 error generated.
shared:ERROR: compiler frontend failed to generate LLVM bitcode, halting

I have verified that I'm receiving the same error no matter what vector type I attempt to register (including primitives). I unfortunately can't stay on the older Emscripten version, due to some other issues.

贡献者指南