Skip to content

register_vector and register_map with raw pointer #21768

Closed

Description

@germanmarques

Up to emscripten 3.1.53 I could register a std::map or std::vector that contained a raw pointer. The methods that returned these vectors and maps are marked with allow_raw_pointers().

register_map<int, MyObject*>("RawObjectsMap");
register_vector<MyObject*>("RawObjectsVector");  

However, starting from version 3.1.54 this code no longer works, getting this error:

static_assert(!std::is_pointer<T*>::value, "Implicitly binding raw pointers is illegal.  Specify allow_raw_pointer<arg<?>>");
|       |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
| /emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:1889:94: note: in instantiation of template class 'emscripten::internal::TypeID<MyObject*>' requested here
|  1889 |     internal::_embind_register_optional(internal::TypeID<std::optional<T>>::get(), internal::TypeID<T>::get());
|       |                                                                                              ^
| /emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:1943:5: note: in instantiation of function template specialization 'emscripten::register_optional<MyObject*>' requested here
|  1943 |     register_optional<T>();

How can I fix it? There's no way to add allow_raw_pointers() to register_vector or register_map. I've checked the documentation and I haven't seen any change that avoids registering maps or vectors with raw pointers.

Thanks!

Versions used:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.56 (cf90417346b78455089e64eb909d71d091ecc055)
clang version 19.0.0git (https:/github.com/llvm/llvm-project 34ba90745fa55777436a2429a51a3799c83c6d4c)

Activity

  1. added 2 commits that reference this issue on Apr 16, 2024
    5150eab
    85e1e49
  2. added a commit that references this issue on Apr 17, 2024
    c95f089
  3. germanmarques commented on Apr 18, 2024

    @germanmarques
    Author

    Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions