Python ctypes callback function to SWIG
问题 I have a SWIG C++ function that expects a function pointer (WNDPROC), and want to give it a Python function that has been wrapped by ctypes.WINFUNCTYPE. It seems to me that this should be compatible, but SWIG's type checking throws an exception because it doesn't know that the ctypes.WINFUNCTYPE type is acctually a WNDPROC. What can I do to pass my callback to SWIG so that it understands it? 回答1: I don't have a windows machine to really check this, but I think you need to create a typemap to