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

Error: no matching member function for call to 'function' (With .h file included) #22653

Open
notsilverhoft opened this issue Sep 29, 2024 · 4 comments
Assignees

Comments

@notsilverhoft
Copy link

notsilverhoft commented Sep 29, 2024

Please include the following in your bug report:

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.67 (2c4461731b8c0bffbdecebc0030e0489712f9886)
clang version 20.0.0git (https:/github.com/llvm/llvm-project b9198a17315757dc0c2e831c9df0498dcab55285)
Target: wasm32-unknown-emscripten
Thread model: posix

Failing command line in full:

  • Command:
em++ --bind CppStuff/BigInteger.cpp -o BigInteger.js -s ALLOW_MEMORY_GROWTH=1 -s EXPORT_ES6=1 -sMODULARIZE -s EXPORT_NAME="BigInt" -v
  • Output:
"/workspaces/codespaces-blank/emsdk/upstream/bin/clang++" -target wasm32-unknown-emscripten -fignore-exceptions -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --sysroot=/workspaces/codespaces-blank/emsdk/upstream/emscripten/cache/sysroot -DEMSCRIPTEN -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -v CppStuff/BigInteger.cpp -c -o /tmp/emscripten_temp_b0xwbf54/BigInteger_0.o
clang version 20.0.0git (https:/github.com/llvm/llvm-project b9198a17315757dc0c2e831c9df0498dcab55285)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /workspaces/codespaces-blank/emsdk/upstream/bin
 (in-process)
 "/workspaces/codespaces-blank/emsdk/upstream/bin/clang-20" -cc1 -triple wasm32-unknown-emscripten -emit-obj -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name BigInteger.cpp -mrelocation-model static -mframe-pointer=none -ffp-contract=on -fno-rounding-math -mconstructor-aliases -target-cpu generic -fvisibility=hidden -debugger-tuning=gdb -fdebug-compilation-dir=/workspaces/codespaces-blank -v -fcoverage-compilation-dir=/workspaces/codespaces-blank -resource-dir /workspaces/codespaces-blank/emsdk/upstream/lib/clang/20 -D EMSCRIPTEN -isysroot /workspaces/codespaces-blank/emsdk/upstream/emscripten/cache/sysroot -internal-isystem /workspaces/codespaces-blank/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten/c++/v1 -internal-isystem /workspaces/codespaces-blank/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1 -internal-isystem /workspaces/codespaces-blank/emsdk/upstream/lib/clang/20/include -internal-isystem /workspaces/codespaces-blank/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten -internal-isystem /workspaces/codespaces-blank/emsdk/upstream/emscripten/cache/sysroot/include -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fignore-exceptions -fexceptions -fcolor-diagnostics -iwithsysroot/include/fakesdl -iwithsysroot/include/compat -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -o /tmp/emscripten_temp_b0xwbf54/BigInteger_0.o -x c++ CppStuff/BigInteger.cpp
clang -cc1 version 20.0.0git based upon LLVM 20.0.0git default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/workspaces/codespaces-blank/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten/c++/v1"
ignoring nonexistent directory "/workspaces/codespaces-blank/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten"
#include "..." search starts here:
#include <...> search starts here:
 /workspaces/codespaces-blank/emsdk/upstream/emscripten/cache/sysroot/include/fakesdl
 /workspaces/codespaces-blank/emsdk/upstream/emscripten/cache/sysroot/include/compat
 /workspaces/codespaces-blank/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1
 /workspaces/codespaces-blank/emsdk/upstream/lib/clang/20/include
 /workspaces/codespaces-blank/emsdk/upstream/emscripten/cache/sysroot/include
End of search list.
In file included from CppStuff/BigInteger.cpp:7:
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:427:17: warning: missing 'typename' prior to dependent type name GetReturnValuePolicy<ReturnType, Rest...>::tag; implicit 'typename' is a C++20 extension [-Wc++20-extensions]
  427 |     using tag = GetReturnValuePolicy<ReturnType, Rest...>::tag;
      |                 ^
      |                 typename 
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:669:26: warning: missing 'typename' prior to dependent type name GetReturnValuePolicy<ReturnType, Policies...>::tag; implicit 'typename' is a C++20 extension [-Wc++20-extensions]
  669 |     using ReturnPolicy = GetReturnValuePolicy<ReturnType, Policies...>::tag;
      |                          ^
      |                          typename 
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:1542:30: warning: missing 'typename' prior to dependent type name GetReturnValuePolicy<ReturnType, Policies...>::tag; implicit 'typename' is a C++20 extension [-Wc++20-extensions]
 1542 |         using ReturnPolicy = GetReturnValuePolicy<ReturnType, Policies...>::tag;
      |                              ^
      |                              typename 
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:1572:30: warning: missing 'typename' prior to dependent type name GetReturnValuePolicy<ReturnType, Policies...>::tag; implicit 'typename' is a C++20 extension [-Wc++20-extensions]
 1572 |         using ReturnPolicy = GetReturnValuePolicy<ReturnType, Policies...>::tag;
      |                              ^
      |                              typename 
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:1603:30: warning: missing 'typename' prior to dependent type name GetReturnValuePolicy<ReturnType, Policies...>::tag; implicit 'typename' is a C++20 extension [-Wc++20-extensions]
 1603 |         using ReturnPolicy = GetReturnValuePolicy<ReturnType, Policies...>::tag;
      |                              ^
      |                              typename 
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:1632:30: warning: missing 'typename' prior to dependent type name GetReturnValuePolicy<ReturnType, Policies...>::tag; implicit 'typename' is a C++20 extension [-Wc++20-extensions]
 1632 |         using ReturnPolicy = GetReturnValuePolicy<ReturnType, Policies...>::tag;
      |                              ^
      |                              typename 
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:1655:30: warning: missing 'typename' prior to dependent type name GetReturnValuePolicy<ReturnType, Policies...>::tag; implicit 'typename' is a C++20 extension [-Wc++20-extensions]
 1655 |         using ReturnPolicy = GetReturnValuePolicy<ReturnType, Policies...>::tag;
      |                              ^
      |                              typename 
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:1767:30: warning: missing 'typename' prior to dependent type name GetReturnValuePolicy<SmartPtr, return_value_policy::take_ownership>::tag; implicit 'typename' is a C++20 extension [-Wc++20-extensions]
 1767 |         using ReturnPolicy = GetReturnValuePolicy<SmartPtr, return_value_policy::take_ownership>::tag;
      |                              ^
      |                              typename 
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:1850:30: warning: missing 'typename' prior to dependent type name GetReturnValuePolicy<FieldType, Policies...>::tag; implicit 'typename' is a C++20 extension [-Wc++20-extensions]
 1850 |         using ReturnPolicy = GetReturnValuePolicy<FieldType, Policies...>::tag;
      |                              ^
      |                              typename 
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:1878:30: warning: missing 'typename' prior to dependent type name GetReturnValuePolicy<FieldType, Policies...>::tag; implicit 'typename' is a C++20 extension [-Wc++20-extensions]
 1878 |         using ReturnPolicy = GetReturnValuePolicy<FieldType, Policies...>::tag;
      |                              ^
      |                              typename 
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:1912:30: warning: missing 'typename' prior to dependent type name GetReturnValuePolicy<typename GP::ReturnType, Policies...>::tag; implicit 'typename' is a C++20 extension [-Wc++20-extensions]
 1912 |         using ReturnPolicy = GetReturnValuePolicy<typename GP::ReturnType, Policies...>::tag;
      |                              ^
      |                              typename 
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:1940:30: warning: missing 'typename' prior to dependent type name GetReturnValuePolicy<PropertyType, Policies...>::tag; implicit 'typename' is a C++20 extension [-Wc++20-extensions]
 1940 |         using ReturnPolicy = GetReturnValuePolicy<PropertyType, Policies...>::tag;
      |                              ^
      |                              typename 
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:1974:30: warning: missing 'typename' prior to dependent type name GetReturnValuePolicy<ReturnType, Policies...>::tag; implicit 'typename' is a C++20 extension [-Wc++20-extensions]
 1974 |         using ReturnPolicy = GetReturnValuePolicy<ReturnType, Policies...>::tag;
      |                              ^
      |                              typename 
CppStuff/BigInteger.cpp:643:10: error: no matching member function for call to 'function'
  625 |         .function("setFromDouble", &avmplus::BigInteger::setFromDouble)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  626 |         .function("setFromBigInteger", &avmplus::BigInteger::setFromBigInteger)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  627 |         .function("doubleValueOf", &avmplus::BigInteger::doubleValueOf)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  628 |         .function("compare", &avmplus::BigInteger::compare)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  629 |         .function("compareOffset", &avmplus::BigInteger::compareOffset)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  630 |         .function("addOrSubtract", &avmplus::BigInteger::addOrSubtract)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  631 |         .function("add", &avmplus::BigInteger::add)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  632 |         .function("subtract", &avmplus::BigInteger::subtract)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  633 |         .function("incrementBy", &avmplus::BigInteger::incrementBy)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  634 |         .function("decrementBy", &avmplus::BigInteger::decrementBy)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  635 |         .function("rshift", &avmplus::BigInteger::rshift)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  636 |         .function("lshift", &avmplus::BigInteger::lshift)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  637 |         .function("lshiftBy", &avmplus::BigInteger::lshiftBy)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  638 |         .function("rshiftBy", &avmplus::BigInteger::rshiftBy)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  639 |         .function("multAndIncrementBy", &avmplus::BigInteger::multAndIncrementBy)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  640 |         .function("multBy", &avmplus::BigInteger::multBy)
      |         ~^~~~~~~~
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:1830:44: note: candidate template ignored: couldn't infer template argument 'Callable'
 1830 |     EMSCRIPTEN_ALWAYS_INLINE const class_& function(const char* methodName, Callable callable, Policies...) const {
      |                                            ^
In file included from CppStuff/BigInteger.cpp:7:
In file included from CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:26:
In file included from /workspaces/codespaces-blank/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/val.h:17:
/workspaces/codespaces-blank/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/wire.h:117:19: error: static assertion failed due to requirement '!std::is_pointer<const avmplus::BigInteger *>::value': Implicitly binding raw pointers is illegal.  Specify allow_raw_pointer<arg<?>>
  117 |     static_assert(!std::is_pointer<T*>::value, "Implicitly binding raw pointers is illegal.  Specify allow_raw_pointer<arg<?>>");
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/workspaces/codespaces-blank/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/wire.h:221:45: note: in instantiation of template class 'emscripten::internal::TypeID<const avmplus::BigInteger *>' requested here
  221 |         static constexpr TYPEID types[] = { TypeID<Args>::get()... };
      |                                             ^
/workspaces/codespaces-blank/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/wire.h:244:16: note: in instantiation of member function 'emscripten::internal::ArgArrayGetter<emscripten::internal::TypeList<void, emscripten::internal::AllowedRawPointer<avmplus::BigInteger>, const avmplus::BigInteger *, int, int>>::get' requested here
  244 |             >::get();
      |                ^
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:1550:18: note: in instantiation of member function 'emscripten::internal::WithPolicies<>::ArgTypeList<void, emscripten::internal::AllowedRawPointer<avmplus::BigInteger>, const avmplus::BigInteger *, int, int>::getTypes' requested here
 1550 |             args.getTypes(),
      |                  ^
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:1836:27: note: in instantiation of function template specialization 'emscripten::internal::RegisterClassMethod<void (avmplus::BigInteger::*)(const avmplus::BigInteger *, int, int)>::invoke<avmplus::BigInteger>' requested here
 1836 |         invoker::template invoke<ClassType, Policies...>(methodName, callable);
      |                           ^
CppStuff/BigInteger.cpp:629:10: note: in instantiation of function template specialization 'emscripten::class_<avmplus::BigInteger>::function<emscripten::internal::DeduceArgumentsTag, void (avmplus::BigInteger::*)(const avmplus::BigInteger *, int, int)>' requested here
  629 |         .function("setFromBigInteger", &avmplus::BigInteger::setFromBigInteger)
      |          ^
In file included from CppStuff/BigInteger.cpp:7:
In file included from CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:26:
In file included from /workspaces/codespaces-blank/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/val.h:17:
/workspaces/codespaces-blank/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/wire.h:117:19: error: static assertion failed due to requirement '!std::is_pointer<avmplus::BigInteger *>::value': Implicitly binding raw pointers is illegal.  Specify allow_raw_pointer<arg<?>>
  117 |     static_assert(!std::is_pointer<T*>::value, "Implicitly binding raw pointers is illegal.  Specify allow_raw_pointer<arg<?>>");
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/workspaces/codespaces-blank/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/wire.h:221:45: note: in instantiation of template class 'emscripten::internal::TypeID<avmplus::BigInteger *>' requested here
  221 |         static constexpr TYPEID types[] = { TypeID<Args>::get()... };
      |                                             ^
/workspaces/codespaces-blank/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/wire.h:244:16: note: in instantiation of member function 'emscripten::internal::ArgArrayGetter<emscripten::internal::TypeList<avmplus::BigInteger *, emscripten::internal::AllowedRawPointer<const avmplus::BigInteger>, const avmplus::BigInteger *, bool, avmplus::BigInteger *>>::get' requested here
  244 |             >::get();
      |                ^
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:1580:18: note: in instantiation of member function 'emscripten::internal::WithPolicies<>::ArgTypeList<avmplus::BigInteger *, emscripten::internal::AllowedRawPointer<const avmplus::BigInteger>, const avmplus::BigInteger *, bool, avmplus::BigInteger *>::getTypes' requested here
 1580 |             args.getTypes(),
      |                  ^
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:1836:27: note: in instantiation of function template specialization 'emscripten::internal::RegisterClassMethod<avmplus::BigInteger *(avmplus::BigInteger::*)(const avmplus::BigInteger *, bool, avmplus::BigInteger *) const>::invoke<avmplus::BigInteger>' requested here
 1836 |         invoker::template invoke<ClassType, Policies...>(methodName, callable);
      |                           ^
CppStuff/BigInteger.cpp:633:10: note: in instantiation of function template specialization 'emscripten::class_<avmplus::BigInteger>::function<emscripten::internal::DeduceArgumentsTag, avmplus::BigInteger *(avmplus::BigInteger::*)(const avmplus::BigInteger *, bool, avmplus::BigInteger *) const>' requested here
  633 |         .function("addOrSubtract", &avmplus::BigInteger::addOrSubtract)
      |          ^
In file included from CppStuff/BigInteger.cpp:7:
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:1912:60: error: implicit instantiation of undefined template 'emscripten::internal::GetterPolicy<const int *>'
 1912 |         using ReturnPolicy = GetReturnValuePolicy<typename GP::ReturnType, Policies...>::tag;
      |                                                            ^
CppStuff/BigInteger.cpp:650:10: note: in instantiation of function template specialization 'emscripten::class_<avmplus::BigInteger>::property<emscripten::internal::DeduceArgumentsTag, const int *, void>' requested here
  650 |         .property("kMaxBigIntegerBufferSize", &avmplus::BigInteger::kMaxBigIntegerBufferSize)
      |          ^
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:827:8: note: template is declared here
  827 | struct GetterPolicy;
      |        ^
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:1913:22: error: implicit instantiation of undefined template 'emscripten::internal::GetterPolicy<const int *>'
 1913 |         auto gter = &GP::template get<ClassType, ReturnPolicy>;
      |                      ^
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:827:8: note: template is declared here
  827 | struct GetterPolicy;
      |        ^
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:1914:75: error: implicit instantiation of undefined template 'emscripten::internal::GetterPolicy<const int *>'
 1914 |         typename WithPolicies<Policies...>::template ArgTypeList<typename GP::ReturnType> returnType;
      |                                                                           ^
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:827:8: note: template is declared here
  827 | struct GetterPolicy;
      |        ^
In file included from CppStuff/BigInteger.cpp:7:
In file included from CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:26:
In file included from /workspaces/codespaces-blank/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/val.h:17:
/workspaces/codespaces-blank/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/wire.h:365:16: error: array 'new' cannot have initialization arguments
  365 |         return new ActualT(v);
      |                ^           ~
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:785:31: note: in instantiation of function template specialization 'emscripten::internal::GenericBindingType<unsigned int[130]>::toWireType<unsigned int (&)[130]>' requested here
  785 |         return MemberBinding::toWireType(ptr.*field, ReturnPolicy{});
      |                               ^
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:1881:69: note: in instantiation of function template specialization 'emscripten::internal::MemberAccess<avmplus::BigInteger, unsigned int[130]>::getWire<avmplus::BigInteger, emscripten::internal::rvp::default_tag>' requested here
 1881 |         auto getter = &MemberAccess<ClassType, FieldType>::template getWire<ClassType, ReturnPolicy>;
      |                                                                     ^
CppStuff/BigInteger.cpp:651:10: note: in instantiation of function template specialization 'emscripten::class_<avmplus::BigInteger>::property<unsigned int[130], void>' requested here
  651 |         .property("wordBuffer", &avmplus::BigInteger::wordBuffer)
      |          ^
In file included from CppStuff/BigInteger.cpp:7:
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:794:20: error: array type 'unsigned int[130]' is not assignable
  794 |         ptr.*field = MemberBinding::fromWireType(value);
      |         ~~~~~~~~~~ ^
CppStuff/../emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:1882:69: note: in instantiation of function template specialization 'emscripten::internal::MemberAccess<avmplus::BigInteger, unsigned int[130]>::setWire<avmplus::BigInteger>' requested here
 1882 |         auto setter = &MemberAccess<ClassType, FieldType>::template setWire<ClassType>;
      |                                                                     ^
CppStuff/BigInteger.cpp:651:10: note: in instantiation of function template specialization 'emscripten::class_<avmplus::BigInteger>::property<unsigned int[130], void>' requested here
  651 |         .property("wordBuffer", &avmplus::BigInteger::wordBuffer)
      |          ^
13 warnings and 8 errors generated.
em++: error: '/workspaces/codespaces-blank/emsdk/upstream/bin/clang++ -target wasm32-unknown-emscripten -fignore-exceptions -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --sysroot=/workspaces/codespaces-blank/emsdk/upstream/emscripten/cache/sysroot -DEMSCRIPTEN -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -v CppStuff/BigInteger.cpp -c -o /tmp/emscripten_temp_b0xwbf54/BigInteger_0.o' failed (returned 1)

My code is in the following files:

I am trying to use the functions nested in the BigInteger class, so I am trying to use EMScripten binding, and I keep getting the same error. I followed the EMScripten documentation pretty closely:

class MyClass {
public:
  MyClass(int x, std::string y)
    : x(x)
    , y(y)
  {}

  void incrementX() {
    ++x;
  }

  int getX() const { return x; }
  void setX(int x_) { x = x_; }

  static std::string getStringFromInstance(const MyClass& instance) {
    return instance.y;
  }

private:
  int x;
  std::string y;
};

// Binding code
EMSCRIPTEN_BINDINGS(my_class_example) {
  class_<MyClass>("MyClass")
    .constructor<int, std::string>()
    .function("incrementX", &MyClass::incrementX)
    .property("x", &MyClass::getX, &MyClass::setX)
    .class_function("getStringFromInstance", &MyClass::getStringFromInstance)
    ;
}
@brendandahl
Copy link
Collaborator

BigInteger.cpp.txt doesn't appear to have any EMSCRIPTEN_BINDINGS. Can you attach the file with the bindings as well?

@notsilverhoft
Copy link
Author

notsilverhoft commented Sep 30, 2024

@brendandahl My apologies, I linked the original file, I corrected the link, and I will link it here as well:
BigInteger.cpp.txt

@brendandahl
Copy link
Collaborator

The error is not helpful in this case, but it's coming from the template matching failing since multBy is overloaded and clang doesn't know which function you want to use. There's the select_overload helper for this. e.g.

.function("multBy", emscripten::select_overload<void(const avmplus::BigInteger *)>(&avmplus::BigInteger::multBy), emscripten::allow_raw_pointers())

@notsilverhoft
Copy link
Author

I am not really sure how to use the select_overload helper, allow_raw_pointers() is the only thing I've tried, and I was having issues. I added your example to my EMSCRIPTEN_BINDINGS , and I got this error:
Implicitly binding raw pointers is illegal. Specify allow_raw_pointer<arg<?>>
I think it has to do with the fact that we are trying to allow raw pointers on a function instead of a property, correct me if I'm wrong. Thanks for your help by the way.

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

No branches or pull requests

2 participants