Work around MinGW mangling of "host:/path"
[msysgit/historical-msysgit.git] / mingw / info / stabs / Structures.html
blob0d9dd45bf0687d99a3fdb3ed8af26d357ca0a23c
1 <html lang="en">
2 <head>
3 <title>STABS</title>
4 <meta http-equiv="Content-Type" content="text/html">
5 <meta name="description" content="STABS">
6 <meta name="generator" content="makeinfo 4.3">
7 <link href="http://www.gnu.org/software/texinfo/" rel="generator-home">
8 </head>
9 <body>
10 <div class="node">
11 <p>
12 Node:<a name="Structures">Structures</a>,
13 Next:<a rel="next" accesskey="n" href="Typedefs.html#Typedefs">Typedefs</a>,
14 Previous:<a rel="previous" accesskey="p" href="Enumerations.html#Enumerations">Enumerations</a>,
15 Up:<a rel="up" accesskey="u" href="Types.html#Types">Types</a>
16 <hr><br>
17 </div>
19 <h3 class="section">Structures</h3>
21 <p>The encoding of structures in stabs can be shown with an example.
23 <p>The following source code declares a structure tag and defines an
24 instance of the structure in global scope. Then a <code>typedef</code> equates the
25 structure tag with a new type. Separate stabs are generated for the
26 structure tag, the structure <code>typedef</code>, and the structure instance. The
27 stabs for the tag and the <code>typedef</code> are emitted when the definitions are
28 encountered. Since the structure elements are not initialized, the
29 stab and code for the structure variable itself is located at the end
30 of the program in the bss section.
32 <pre class="example"> struct s_tag {
33 int s_int;
34 float s_float;
35 char s_char_vec[8];
36 struct s_tag* s_next;
37 } g_an_s;
39 typedef struct s_tag s_typedef;
40 </pre>
42 <p>The structure tag has an <code>N_LSYM</code> stab type because, like the
43 enumeration, the symbol has file scope. Like the enumeration, the
44 symbol descriptor is <code>T</code>, for enumeration, structure, or tag type.
45 The type descriptor <code>s</code> following the <code>16=</code> of the type
46 definition narrows the symbol type to structure.
48 <p>Following the <code>s</code> type descriptor is the number of bytes the
49 structure occupies, followed by a description of each structure element.
50 The structure element descriptions are of the form <var>name:type, bit
51 offset from the start of the struct, number of bits in the element</var>.
53 <pre class="example"> # 128 is N_LSYM
54 .stabs "s_tag:T16=s20s_int:1,0,32;s_float:12,32,32;
55 s_char_vec:17=ar1;0;7;2,64,64;s_next:18=*16,128,32;;",128,0,0,0
56 </pre>
58 <p>In this example, the first two structure elements are previously defined
59 types. For these, the type following the <code></code><var>name</var><code>:</code> part of the
60 element description is a simple type reference. The other two structure
61 elements are new types. In this case there is a type definition
62 embedded after the <code></code><var>name</var><code>:</code>. The type definition for the
63 array element looks just like a type definition for a stand-alone array.
64 The <code>s_next</code> field is a pointer to the same kind of structure that
65 the field is an element of. So the definition of structure type 16
66 contains a type definition for an element which is a pointer to type 16.
68 <p>If a field is a static member (this is a C++ feature in which a single
69 variable appears to be a field of every structure of a given type) it
70 still starts out with the field name, a colon, and the type, but then
71 instead of a comma, bit position, comma, and bit size, there is a colon
72 followed by the name of the variable which each such field refers to.
74 <p>If the structure has methods (a C++ feature), they follow the non-method
75 fields; see <a href="Cplusplus.html#Cplusplus">Cplusplus</a>.
77 </body></html>