I’d like to do the following:
cdef extern from "foo.h" namespace "foo":
int bar(int, int)
def bar(a, b):
return foo.bar(a, b)
But this does not work. What is the namespace "foo" part for ? And how can I achieve to load the functions externed from “foo.h” into an object named foo ?
Update:
I could find a solution using the following file-structure and code:
spam.pyx
spam_c.pxd
c\
spam.c
# spam.pyx
cimport spam_c as spam
def foo(a, b):
return spam.foo(a, b)
# spam_c.pxd
cdef extern from "spam.c":
double foo(double, double)
Is there a better way to solve this ?
I have found out that this is the preferred way to deal with this.