What do the parentheseses mean in the c code? [duplicate]
I'm not even a beginner of c language.
and I see the codes from cpython source code:
typedef struct _formatdef {
char format;
Py_ssize_t size;
Py_ssize_t alignment;
PyObject* (*unpack)(_structmodulestate *, const char *,
const struct _formatdef *);
int (*pack)(_structmodulestate *, char *, PyObject *,
const struct _formatdef *);
} formatdef;
in the 5th line, I know that PyObject*
is defining a pointer to a variable of PyObject type, however what does (*unpack)
mean? and what does the following (_structmodulestate *)
mean?
It's a function pointer declaration.
This:
float x;
declares a variable of type float
named x
.
This:
float *p;
declares a variable of type float*
(a pointer to a float
) named p
.
This:
int foo(float *p);
declares a function named foo
, which takes a float*
as an argument, and returns an int
.
This:
PyObject* (*unpack)(_structmodulestate *, const char *, const struct _formatdef *);
declares a function pointer named unpack
, which points to a function which takes three pointers (of various types) as arguments, and returns a PyObject*
.