Running C code from jitted function

Hi, I’m trying to call a function from a C library (GSL) within a jitted function. I think the way to do it is with a WrapperAddressProtocol object. However, I tried the example code here:

https://numba.pydata.org/numba-doc/latest/reference/types.html#wrapper-address-protocol-wap

and it gives the following error:

numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
non-precise type pyobject
During: typing of argument at /home/beno/Dropbox/Szakma/Research/BayesHopperRealistic/Code/GSL/ctype_test.py (13)

File "ctype_test.py", line 13:
def foo(f, x):
    return f(x)
    ^

Am I doing something wrong here? Or is this a bug?

Also, if this is not the easiest way to call a C executable from a jitted function, I’m open to suggestions.

Thanks a lot!

I reported this in the issue tracker. But as a quick fix, try to add the following import at the top of your script:

from numba.experimental import function_type

This should make Numba aware of the WAP protocol