typedef总结
AI摘要
GPT
前言
最近开始看python的源码,然后呢,在C的头文件中总看见类似这样的定义:1
2
3
4
5
6
7
8
9
10typedef PyObject * (*unaryfunc)(PyObject *);
typedef PyObject * (*binaryfunc)(PyObject *, PyObject *);
typedef PyObject * (*ternaryfunc)(PyObject *, PyObject *, PyObject *);
typedef int (*inquiry)(PyObject *);
typedef Py_ssize_t (*lenfunc)(PyObject *);
typedef PyObject *(*ssizeargfunc)(PyObject *, Py_ssize_t);
typedef PyObject *(*ssizessizeargfunc)(PyObject *, Py_ssize_t, Py_ssize_t);
typedef int(*ssizeobjargproc)(PyObject *, Py_ssize_t, PyObject *);
typedef int(*ssizessizeobjargproc)(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *);
typedef int(*objobjargproc)(PyObject *, PyObject *, PyObject *);
咦,typedef
不就是给类型定义别名么,怎么跟我记忆中常见的不太一样?
后面这几大坨是什么意思?后面只有一坨也可以?
嗯,大概我需要重新了解一下typedef
的用法了。