在c++中调用julia函数,官方例子中给出的是调用Base包中的函数,在调用jl_get_function函数时,第一个参数是jl_base_module
jl_init();
jl_function_t *func = jl_get_function(jl_base_module, “sqrt”);
jl_value_t *argument = jl_box_float64(2.0);
jl_value_t *ret = jl_call1(func, argument);
if (jl_typeis(ret,jl_float64_type)) {
double ret_unboxed = jl_unbox_float64(ret);
printf(“sqrt(2.0) in C: %e \n”, ret_unboxed);
}
如果我自己编写了一个module,如下:我如何通过jl_get_function获取testModule中的testfun函数指针???谢谢!
module testModule
export testfun
function testfun()
println(“Test \n”)
end