Skip to content

Instantly share code, notes, and snippets.

@alistra
Created May 29, 2013 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alistra/5668955 to your computer and use it in GitHub Desktop.
Save alistra/5668955 to your computer and use it in GitHub Desktop.
#include <emscripten/bind.h>
using namespace emscripten;
using namespace std;
struct Ssss {
char *c;
int x;
};
EMSCRIPTEN_BINDINGS(my_value_example) {
value_struct<Ssss>("Ssss")
.field("c", &Ssss::c)
.field("x", &Ssss::x)
;
}
//the error:
/Users/aleksander/emscripten/system/include/emscripten/wire.h:41:13: error: static_assert failed "Implicitly binding raw pointers is illegal. Specify allow_raw_pointer<arg<?>>"
static_assert(!std::is_pointer<T*>::value, "Implicitly binding raw pointers is illegal. Specify allow_raw_pointer<arg<?>>");
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/aleksander/emscripten/system/include/emscripten/bind.h:625:17: note: in instantiation of template class 'emscripten::internal::TypeID<char *>' requested here
TypeID<FieldType>::get(),
^
bindings.cpp:49:14: note: in instantiation of function template specialization 'emscripten::value_struct<Ssss>::field<Ssss, char *>' requested here
.field("c", &Ssss::c)
^
In file included from bindings.cpp:1:
/Users/aleksander/emscripten/system/include/emscripten/bind.h:625:34: error: incomplete definition of type 'emscripten::internal::TypeID<char *>'
TypeID<FieldType>::get(),
~~~~~~~~~~~~~~~~~^~
bindings.cpp:49:14: note: in instantiation of function template specialization 'emscripten::value_struct<Ssss>::field<Ssss, char *>' requested here
.field("c", &Ssss::c)
^
2 errors generated.
ERROR emcc: compiler frontend failed to generate LLVM bitcode, halting
//when I add allow_raw_pointers()
struct Ssss {
char *c;
int x;
};
EMSCRIPTEN_BINDINGS(my_value_example) {
value_struct<Ssss>("Ssss")
.field("c", &Ssss::c, allow_raw_pointers())
.field("x", &Ssss::x)
;
}
// error:
/Users/aleksander/emscripten/system/include/emscripten/bind.h:650:33: error: implicit instantiation of undefined template 'emscripten::internal::GetterPolicy<char *Ssss::*>'
TypeID<typename GP::ReturnType>::get(),
^
bindings.cpp:49:14: note: in instantiation of function template specialization 'emscripten::value_struct<Ssss>::field<char *Ssss::*, emscripten::allow_raw_pointers>' requested here
.field("c", &Ssss::c, allow_raw_pointers())
^
/Users/aleksander/emscripten/system/include/emscripten/bind.h:426:16: note: template is declared here
struct GetterPolicy;
^
1 error generated.
ERROR emcc: compiler frontend failed to generate LLVM bitcode, halting
@OliverXH
Copy link

OliverXH commented Aug 3, 2022

Have you solved this problem?
I found this: https://gist.github.com/AlexPerrot/5d8a3aa0eacf7f3de5478ec1164c834e

@alistra
Copy link
Author

alistra commented Aug 3, 2022

no idea bro it was for a job interview 9 years ago

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