Hello,
I am trying to use a simple C++ program containing using std::function with Embind. However, the latter does not seem to recognize std::function.
More specifically, here is the example I used:
Foo.cpp
#include <functional>
#include <emscripten/bind.h>
using namespace emscripten;
int bar(std::function<int(int)> func, int num) {
return func(num);
}
EMSCRIPTEN_BINDINGS(Foo) {
function("bar", &bar);
}
Foo.html
<!doctype html>
<html>
<script src="foo.js"></script>
<script>
console.log('Foo: ' + Module.bar);
</script>
</html>
Compilation
$ emcc --bind foo.cpp -o foo.js
The compilation succeeds with no errors or warnings.
Result
Result
Generated source code
I should also mention that I tried many different combinations, e.g. std::function with different types, as return type, as argument, as an independent function (like in the above example), as a class or struct method, but had no luck.
Any ideas would prove of great help.
Thank you very much, in advance.
― Vangelis