Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r1378:f37a06c4c060 Date: 2013-10-21 14:31 +0200 http://bitbucket.org/cffi/cffi/changeset/f37a06c4c060/
Log: Document the workaround for taking pointers to functions. diff --git a/doc/source/index.rst b/doc/source/index.rst --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -981,6 +981,17 @@ Aside from these limitations, functions and callbacks can return structs. +CPython only: for performance, ``ffi.verify()`` returns functions as +objects of type ``<built-in function>``. They are not ``<cdata>``, so +you cannot e.g. pass them to some other C function expecting a function +pointer argument. Only ``ffi.typeof()`` works on them. If you really +need a pointer to the function, use the following workaround:: + + ffi.cdef(""" int (*foo)(int a, int b); """) + +i.e. declare them as pointer-to-function in the cdef (even if they are +regular functions in the C code). + Variadic function calls ----------------------- _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit