Static inline functions in header files, limited API and the stable ABI

Hi, Is it ok to add a static inline function to the limited API? Can it cause ABI issue? Or is it safer to add a regular function? For example, is it safe to add the following function to the limited API? static inline PyObject * _PyObject_CallOneArg(PyObject *func, PyObject *arg) { ... return _PyObject_VectorcallTstate(tstate, func, args, nargsf, NULL); } Or should it be an opaque definition like the following function? PyAPI_FUNC(PyObject *) PyObject_CallNoArgs(PyObject *func); I came to this question while reviewing "Make Vectorcall public" C API: https://bugs.python.org/issue39245 https://github.com/python/cpython/pull/17893 Victor -- Night gathers, and now my watch begins. It shall not end until my death.

Victor Stinner wrote:
Hi, Is it ok to add a static inline function to the limited API? Can it cause ABI issue? Or is it safer to add a regular function? For example, is it safe to add the following function to the limited API? static inline PyObject _PyObject_CallOneArg(PyObject func, PyObject *arg) { ... return _PyObject_VectorcallTstate(tstate, func, args, nargsf, NULL); } Or should it be an opaque definition like the following function? PyAPI_FUNC(PyObject ) PyObject_CallNoArgs(PyObject func);
Yes, it should need the opaque definition. Otherwise we'd need to ensure ABI compatibility for _PyObject_VectorcallTstate and we would need to support the exact definition of the static inline function "forever".
I came to this question while reviewing "Make Vectorcall public" C API: https://bugs.python.org/issue39245 https://github.com/python/cpython/pull/17893
Just to clarify, that PR does not propose adding things to the limited API.
participants (2)
-
encukou@gmail.com
-
Victor Stinner