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

Errors when calling jlcxx::make_function_pointer #71

Open
benjaminfaber opened this issue Nov 9, 2020 · 0 comments
Open

Errors when calling jlcxx::make_function_pointer #71

benjaminfaber opened this issue Nov 9, 2020 · 0 comments

Comments

@benjaminfaber
Copy link

Hi, I am attempting to use CxxWrap to expose a C++ library to Julia, and I would like to pass a Julia function as a callback to the library. However, when I attempt to use jlcxx::make_function_pointer, I receive an error that some of the arguments of the signature for the function pointer I'm attempting to convert have no Julia wrapper. A MWE is below:

#include "jlcxx/jlcxx.hpp"
#include "jlcxx/functions.hpp"

class test_class {
};

JLCXX_MODULE define_julia_module(jlcxx::Module& mod) {
  mod.method("pass_func",[](jlcxx::SafeCFunction f_data) {
    auto f = jlcxx::make_function_pointer<void(int*,test_class*)>(f_data);
    });
}
julia> module wrapped
            using CxxWrap
            @wrapmodule(joinpath("lib/path","lib"))
            function __init__()
              @initcxx
            end
          end

julia> function testfunc(i::Int,c::wrapped.test_class)
          end

julia> cxxtestfunc = @safe_cfunction(testfunc, Cvoid, (CxxPtr{Cint},CxxPtr{wrapped.test_class}));

julia> wrapped.pass_func(cxxtestfunc)
ERROR: Type Pi has no Julia wrapper

This error does not arise if a double* is specified in the function pointer signature, which makes me think this is a bug, or am I just using libcxxwrap incorrectly?

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

1 participant