Struct with a pointer to a native type in ctypes

I am trying to map a structure definition using ctypes:

struct attrl {
               struct attrl *next;
               char         *name;
               char         *resource;
               char         *value;
           };

I'm not sure what to do with the “next” field of the structure in the ctypes mapping. Type Definition:

class attrl(Structure):
    _fields_ = [
        ("next", attrl),
        ("name", c_char_p), 
        ("resource", c_char_p), 
        ("value", c_char_p)
    ]

leads to:

NameError: name 'attrl' is not defined
+3
source share
1 answer

You will need the equivalent of a direct ad as described here .

+3
source

Source: https://habr.com/ru/post/1703144/


All Articles