jin-eld / cffi-callback-test

Test code to debug C->Python CFFI callbacks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CFFI C to Python callacks: cffi_start_python() initialization workaround

The cffi embedding docs say, that one can call cffi_start_python() directly in order to force Python initialization when needed. However, the function is being generated with a static declaration, which makes it impossible to call it from main().

This example presents a workaround by injecting a non static wrapper function into the generated code via ffibuilder.set_source().

Build

To enable -O0 -g run configure with the --enable-debug parameter.

autoreconf -if
./configure
make

Run

After building run:

./cbtest

Press Ctrl-C to quit.

About

Test code to debug C->Python CFFI callbacks


Languages

Language:M4 90.9%Language:Python 3.6%Language:C 3.3%Language:Makefile 2.2%