Replace a function pointer in a shared library with ctypes
问题 I am trying to replace an existing function pointer in a shared library with a callback defined in Python, through ctypes. The source of the shared library in C: #include <assert.h> #include <stdio.h> void (*plot)(); int c_main(int argc, void** argv) { printf("plot is %p\n", (void*)plot); assert(plot != NULL); plot(); return 0; } The source of the Python script: from sys import platform from pathlib import Path import ctypes import _ctypes FUNCTYPE = ctypes.WINFUNCTYPE if platform == 'win32'