You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
6.2 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1992-2019 Free Software Foundation, Inc.
Contributed by Cygnus Support. Written by Julia Menapace, Jim Kingdon,
and David MacKenzie.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
Texts. A copy of the license is included in the section entitled "GNU
Free Documentation License". -->
<!-- Created by GNU Texinfo 6.4, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Enumerations (STABS)</title>
<meta name="description" content="Enumerations (STABS)">
<meta name="keywords" content="Enumerations (STABS)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Symbol-Types-Index.html#Symbol-Types-Index" rel="index" title="Symbol Types Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Types.html#Types" rel="up" title="Types">
<link href="Structures.html#Structures" rel="next" title="Structures">
<link href="Strings.html#Strings" rel="prev" title="Strings">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en">
<a name="Enumerations"></a>
<div class="header">
<p>
Next: <a href="Structures.html#Structures" accesskey="n" rel="next">Structures</a>, Previous: <a href="Strings.html#Strings" accesskey="p" rel="prev">Strings</a>, Up: <a href="Types.html#Types" accesskey="u" rel="up">Types</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Symbol-Types-Index.html#Symbol-Types-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Enumerations-1"></a>
<h3 class="section">5.7 Enumerations</h3>
<p>Enumerations are defined with the &lsquo;<samp>e</samp>&rsquo; type descriptor.
</p>
<p>The source line below declares an enumeration type at file scope.
The type definition is located after the <code>N_RBRAC</code> that marks the end of
the previous procedure&rsquo;s block scope, and before the <code>N_FUN</code> that marks
the beginning of the next procedure&rsquo;s block scope. Therefore it does not
describe a block local symbol, but a file local one.
</p>
<p>The source line:
</p>
<div class="example">
<pre class="example">enum e_places {first,second=3,last};
</pre></div>
<p>generates the following stab:
</p>
<div class="example">
<pre class="example">.stabs &quot;e_places:T22=efirst:0,second:3,last:4,;&quot;,128,0,0,0
</pre></div>
<p>The symbol descriptor (&lsquo;<samp>T</samp>&rsquo;) says that the stab describes a
structure, enumeration, or union tag. The type descriptor &lsquo;<samp>e</samp>&rsquo;,
following the &lsquo;<samp>22=</samp>&rsquo; of the type definition narrows it down to an
enumeration type. Following the &lsquo;<samp>e</samp>&rsquo; is a list of the elements of
the enumeration. The format is &lsquo;<samp><var>name</var>:<var>value</var>,</samp>&rsquo;. The
list of elements ends with &lsquo;<samp>;</samp>&rsquo;. The fact that <var>value</var> is
specified as an integer can cause problems if the value is large. GCC
2.5.2 tries to output it in octal in that case with a leading zero,
which is probably a good thing, although GDB 4.11 supports octal only in
cases where decimal is perfectly good. Negative decimal values are
supported by both GDB and dbx.
</p>
<p>There is no standard way to specify the size of an enumeration type; it
is determined by the architecture (normally all enumerations types are
32 bits). Type attributes can be used to specify an enumeration type of
another size for debuggers which support them; see <a href="String-Field.html#String-Field">String Field</a>.
</p>
<p>Enumeration types are unusual in that they define symbols for the
enumeration values (<code>first</code>, <code>second</code>, and <code>third</code> in the
above example), and even though these symbols are visible in the file as
a whole (rather than being in a more local namespace like structure
member names), they are defined in the type definition for the
enumeration type rather than each having their own symbol. In order to
be fast, GDB will only get symbols from such types (in its initial scan
of the stabs) if the type is the first thing defined after a &lsquo;<samp>T</samp>&rsquo; or
&lsquo;<samp>t</samp>&rsquo; symbol descriptor (the above example fulfills this
requirement). If the type does not have a name, the compiler should
emit it in a nameless stab (see <a href="String-Field.html#String-Field">String Field</a>); GCC does this.
</p>
<hr>
<div class="header">
<p>
Next: <a href="Structures.html#Structures" accesskey="n" rel="next">Structures</a>, Previous: <a href="Strings.html#Strings" accesskey="p" rel="prev">Strings</a>, Up: <a href="Types.html#Types" accesskey="u" rel="up">Types</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Symbol-Types-Index.html#Symbol-Types-Index" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>