Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

register_vector and register_map with raw pointer #21768

Closed
germanmarques opened this issue Apr 16, 2024 · 1 comment · Fixed by #21769
Closed

register_vector and register_map with raw pointer #21768

germanmarques opened this issue Apr 16, 2024 · 1 comment · Fixed by #21769
Assignees
Labels

Comments

@germanmarques
Copy link

germanmarques commented Apr 16, 2024

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)
brendandahl added a commit to brendandahl/emscripten that referenced this issue Apr 16, 2024
Previously, register_vector and register_map didn't used std::optional,
but allowed pointers. After changing them to use std::optional, pointers
were no longer were allowed. This restores the previous behavior.

Fixes emscripten-core#21768
brendandahl added a commit to brendandahl/emscripten that referenced this issue Apr 16, 2024
Previously, register_vector and register_map didn't use std::optional,
but allowed pointers. After changing them to use std::optional, pointers
were no longer were allowed. This restores the previous behavior.

Fixes emscripten-core#21768
brendandahl added a commit that referenced this issue Apr 17, 2024
Previously, register_vector and register_map didn't use std::optional,
but allowed pointers. After changing them to use std::optional, pointers
were no longer were allowed. This restores the previous behavior.

Fixes #21768
@germanmarques
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants