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">
12 Node:
<a name=
"Enumerations">Enumerations
</a>,
13 Next:
<a rel=
"next" accesskey=
"n" href=
"Structures.html#Structures">Structures
</a>,
14 Previous:
<a rel=
"previous" accesskey=
"p" href=
"Strings.html#Strings">Strings
</a>,
15 Up:
<a rel=
"up" accesskey=
"u" href=
"Types.html#Types">Types
</a>
19 <h3 class=
"section">Enumerations
</h3>
21 <p>Enumerations are defined with the
<code>e
</code> type descriptor.
23 <p>The source line below declares an enumeration type at file scope.
24 The type definition is located after the
<code>N_RBRAC
</code> that marks the end of
25 the previous procedure's block scope, and before the
<code>N_FUN
</code> that marks
26 the beginning of the next procedure's block scope. Therefore it does not
27 describe a block local symbol, but a file local one.
31 <pre class=
"example"> enum e_places {first,second=
3,last};
34 <p>generates the following stab:
36 <pre class=
"example"> .stabs
"e_places:T22=efirst:0,second:3,last:4,;",
128,
0,
0,
0
39 <p>The symbol descriptor (
<code>T
</code>) says that the stab describes a
40 structure, enumeration, or union tag. The type descriptor
<code>e
</code>,
41 following the
<code>22=
</code> of the type definition narrows it down to an
42 enumeration type. Following the
<code>e
</code> is a list of the elements of
43 the enumeration. The format is
<code></code><var>name
</var><code>:
</code><var>value
</var><code>,
</code>. The
44 list of elements ends with
<code>;
</code>. The fact that
<var>value
</var> is
45 specified as an integer can cause problems if the value is large. GCC
46 2.5.2 tries to output it in octal in that case with a leading zero,
47 which is probably a good thing, although GDB
4.11 supports octal only in
48 cases where decimal is perfectly good. Negative decimal values are
49 supported by both GDB and dbx.
51 <p>There is no standard way to specify the size of an enumeration type; it
52 is determined by the architecture (normally all enumerations types are
53 32 bits). Type attributes can be used to specify an enumeration type of
54 another size for debuggers which support them; see
<a href=
"String-Field.html#String%20Field">String Field
</a>.
56 <p>Enumeration types are unusual in that they define symbols for the
57 enumeration values (
<code>first
</code>,
<code>second
</code>, and
<code>third
</code> in the
58 above example), and even though these symbols are visible in the file as
59 a whole (rather than being in a more local namespace like structure
60 member names), they are defined in the type definition for the
61 enumeration type rather than each having their own symbol. In order to
62 be fast, GDB will only get symbols from such types (in its initial scan
63 of the stabs) if the type is the first thing defined after a
<code>T
</code> or
64 <code>t
</code> symbol descriptor (the above example fulfills this
65 requirement). If the type does not have a name, the compiler should
66 emit it in a nameless stab (see
<a href=
"String-Field.html#String%20Field">String Field
</a>); GCC does this.