Normally what a typedef does is
typedef DATATYPE NEW_NAME
However, the following is a bit complex and seems like mixing with some other concepts (like the tuple-alike guy)
typedef PyObject *(*newfunc)(struct _typeobject *, PyObject *, PyObject *);
Normally what a typedef does is
typedef DATATYPE NEW_NAME
However, the following is a bit complex and seems like mixing with some other concepts (like the tuple-alike guy)
typedef PyObject *(*newfunc)(struct _typeobject *, PyObject *, PyObject *);
The definition looks confusing since function pointers are confusing at first. The definition
typedef PyObject *(*newfunc)(struct _typeobject *, PyObject *, PyObject *);
Means “create a typedef named newfunc
that is a function taking in a struct _typeobject*
and two PyObject*
s and returns a PyObject*
. The name is after the return type in the middle like it would be with a regular function definition:
PyObject *somefunc(struct _typeobject *, PyObject *, PyObject *);
As it’s a function pointer it needs parentheses and another * to show it is a pointer and the datatype is around the name.