如何使用ctypes
在python中表示圆形struct
?
链表可以用下面的c语言表示
typedef struct LinkedList LinkedList;
typedef struct Node Node;
struct Node
{
int value;
Node* next;
};
struct LinkedList
{
Node* start;
int length;
};
如何使用ctypes
在python中表示相同的struct
.
from ctypes import *
class Node(Structure):
_fields_ = [
("value", c_int),
("next", pointer(Node))
]
但上面给出了以下错误
NameError: name 'Node' is not defined