Typedef with and without struct name

Viewed 1445

I saw the following oddity in the XCB API header. Most types are defined with a type alias and a struct name in this way:

typedef struct xcb_window_iterator_t {
    xcb_window_t *data;
    int rem;
    int index;
} xcb_window_iterator_t;

But some typedefs omit the struct name.

typedef struct {
    unsigned int sequence;
} xcb_void_cookie_t;

What does this mean from the C point of view?

Is the latter a type with a name and a struct without a name? Or is it no type but only a struct with a name?

My confusion comes from the output of the gccxml.

For xcb_window_iterator_t it generates a Struct node:

$ xmllint --format --xpath '//Struct[@name="xcb_window_iterator_t"]' xcb.xml 
<Struct id="_199" name="xcb_window_iterator_t" context="_1" mangled="21xcb_window_iterator_t" demangled="xcb_window_iterator_t" location="f0:43" file="f0" line="43" artificial="1" size="128" align="64" members="_2240 _2241 _2242 _2243 _2244 _2245 _2246 " bases=""/>

and a Typedef node:

$ xmllint --format --xpath '//Typedef[@name="xcb_window_iterator_t"]' xcb.xml 
<Typedef id="_200" name="xcb_window_iterator_t" type="_199" context="_1" location="f0:47" file="f0" line="47"/>

But for xcb_void_cookie_t it generates just a Struct node:

$ xmllint --format --xpath '//Struct[@name="xcb_void_cookie_t"]' xcb.xml 
<Struct id="_967" name="xcb_void_cookie_t" context="_1" mangled="17xcb_void_cookie_t" demangled="xcb_void_cookie_t" location="f14:189" file="f14" line="189" size="32" align="32" members="_3655 _3656 _3657 _3658 _3659 " bases=""/>

But no Typedef node:

$ xmllint --format --xpath '//Typedef[@name="xcb_void_cookie_t"]' xcb.xml 
XPath set is empty

Does this mean xcb_void_cookie_t is no type but just a struct, although the code contains the typedef? Or is it a bug in gccxml?

3 Answers
Related