4

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

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.