[Python] Using enums in ctypes.Structure

Discussão em 'Python' iniciado por Stack, Outubro 25, 2024.

  1. Stack

    Stack Membro Participativo

    I have a struct I'm accessing via ctypes:

    struct attrl {
    char *name;
    char *resource;
    char *value;
    struct attrl *next;
    enum batch_op op;
    };


    So far I have Python code like:

    # struct attropl
    class attropl(Structure):
    pass
    attrl._fields_ = [
    ("next", POINTER(attropl)),
    ("name", c_char_p),
    ("resource", c_char_p),
    ("value", c_char_p),


    But I'm not sure what to use for the batch_op enum. Should I just map it to a c_int or ?

    Continue reading...

Compartilhe esta Página