File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -94,6 +94,40 @@ t = definition_to_type("""
9494
9595The last struct in the definition is returned. All previous structs are cached and available for forward references.
9696
97+ ## Typedefs
98+
99+ The parser supports ` typedef ` declarations. Typedefs are resolved when used as field types in subsequent structs:
100+
101+ ``` python
102+ t = definition_to_type("""
103+ typedef unsigned int uint32_t;
104+ struct S { uint32_t x; };
105+ """ )
106+ ```
107+
108+ Struct typedefs, pointer typedefs, and chained typedefs all work:
109+
110+ ``` python
111+ # Struct typedef
112+ t = definition_to_type("""
113+ typedef struct { int x; int y; } Point;
114+ struct S { Point p; };
115+ """ )
116+
117+ # Pointer typedef
118+ t = definition_to_type("""
119+ typedef int *intptr;
120+ struct S { intptr p; };
121+ """ )
122+
123+ # Chained typedef
124+ t = definition_to_type("""
125+ typedef unsigned int u32;
126+ typedef u32 mytype;
127+ struct S { mytype x; };
128+ """ )
129+ ```
130+
97131## Include Directives
98132
99133The parser supports ` #include ` directives by running the C preprocessor:
You can’t perform that action at this time.
0 commit comments