I would like to be able to use C/C++ functions from python using ctypes python module.
I have a function int doit()
in the .c
/ .cpp
file. When I try to load the shared library:
Frr=CDLL("/path/FoCpy2/libFrr.so")
Frr.doit(c_int(5))
i find it working really well when the .c
variant is used. When C++ is called the good way to call this function is (found out using nm libFrr.so
using nm -gC libFrr.so
produces just plain doit()
):
Frr._Z4doitv(c_int(5))
I have read on Stackexchange that there is no standard way to call C++ from python, and there is "nonstandard name mangling" issue. Is the "Z4" a part of that issue? I guess the nonstandard name mangling would appear for more advanced language features such as class methods, templates, but also for such basic functions? Is it possible to force using simple C function names in simple cases for the C++ code?