Enums with pointers in struct definitions
<p>I am working on creating access to a dynamic library in python using the ctypes module.  While duplicating some of the tydef'd structures in my python implementation I came across a bit of code that has me stumped as to what is happening.  Basically what I have is</p>

<pre><code>enum foo {
    a,
    b,
    c,
};

typedef struct barStruct bar;

struct barStruct{
    enum foo (*lem)();
    enum foo (*baz)(bar *next);
}
</code></pre>

<p>in a header file.</p>

<p>I am trying to understand the two enum calls in the struct definition.  I thought that the first one was creating a pointer called <code>lem</code> which has to point to values contained in the enumeration (so I essentially ignored the open/close parenthesis at the end).  When I noticed the second one, with another pointer in the parenthesis, then I got really confused as to what is going on, and doubted my guess as to what the first one meant.</p>

<p>I apologize if this question already has an answer (which I'm sure it does) but unfortunately I cannot think of how to effectively search for what I need.</p>

<p>Those aren't "enum calls", those are declaring two members in the structure, members that are pointers to functions.</p>

<p>For example</p>

<pre><code>enum foo (*lem)();
</code></pre>

<p>declares a structure member variable <code>lem</code> that is a pointer to a function taking an indeterminate number of arguments, and <em>returns</em> a <code>foo</code> enumeration.</p>

python c pointers enums ctypes