Skip to content

Declare functions for PyMethodDef as 'extern "C"'

David Gobbi requested to merge dgobbi/vtk:python-methods-extern-C into master

If a function is declared in C++, a pointer to this function is not strictly guaranteed to be usable from C even if it only uses C types for its parameters and return value. This causes errors when VTK is checked by UBSan. By adding 'extern "C"', we hope to clearly define the behavior of the compiler with respect to these functions.

One concern is that the function pointers we use in the wrappers are pointers to static functions. If a function is static, then 'extern "C"' is unlikely to have any effect on it. We could potentially remove the 'static' and allow visibility between translation units but not between shared objects.

All of this seems rather extreme for a problem that is, at this point, purely hypothetical.

Edited by David Gobbi

Merge request reports