0
我讀CPython的源代碼,我感到困惑,這些PyXXXObject, 這是cpython中的循環定義嗎?
我覺得這是一個循環定義
它的工作!
#include <stdio.h>
#include <stdlib.h>
typedef struct _object {
struct _typeobject *ob_type; // because it's a pointer!
} PyObject;
typedef struct {
PyObject ob_base;
} PyVarObject;
#define PyObject_VAR_HEAD PyVarObject ob_base;
typedef struct _typeobject {
PyObject_VAR_HEAD
const char *tp_name;
} PyTypeObject;
int main(int argc, char **argv) {
PyVarObject var;
return 0;
}
當然,這很好! https://ideone.com/0gnqt7'struct_object'中的ob_type'有一個指針。 – Ryan