tags:

views:

263

answers:

1

I'm trying to map a struct definition using ctypes:

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

I'm unsure what to do with the "next" field of the struct in the ctypes mapping. A definition like:

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

results in:

NameError: name 'attrl' is not defined
+2  A: 

You need the equivalent of a forward declaration, as described here.

Morendil
Perfect. Good tutorial too.
Kamil Kisiel