1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html> 3<!-- Copyright (C) 1992-2021 Free Software Foundation, Inc. 4Contributed by Cygnus Support. Written by Julia Menapace, Jim Kingdon, 5and David MacKenzie. 6 7Permission is granted to copy, distribute and/or modify this document 8under the terms of the GNU Free Documentation License, Version 1.3 or 9any later version published by the Free Software Foundation; with no 10Invariant Sections, with no Front-Cover Texts, and with no Back-Cover 11Texts. A copy of the license is included in the section entitled "GNU 12Free Documentation License". --> 13<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ --> 14<head> 15<title>STABS: Enumerations</title> 16 17<meta name="description" content="STABS: Enumerations"> 18<meta name="keywords" content="STABS: Enumerations"> 19<meta name="resource-type" content="document"> 20<meta name="distribution" content="global"> 21<meta name="Generator" content="makeinfo"> 22<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 23<link href="index.html#Top" rel="start" title="Top"> 24<link href="Symbol-Types-Index.html#Symbol-Types-Index" rel="index" title="Symbol Types Index"> 25<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> 26<link href="Types.html#Types" rel="up" title="Types"> 27<link href="Structures.html#Structures" rel="next" title="Structures"> 28<link href="Strings.html#Strings" rel="previous" title="Strings"> 29<style type="text/css"> 30<!-- 31a.summary-letter {text-decoration: none} 32blockquote.smallquotation {font-size: smaller} 33div.display {margin-left: 3.2em} 34div.example {margin-left: 3.2em} 35div.indentedblock {margin-left: 3.2em} 36div.lisp {margin-left: 3.2em} 37div.smalldisplay {margin-left: 3.2em} 38div.smallexample {margin-left: 3.2em} 39div.smallindentedblock {margin-left: 3.2em; font-size: smaller} 40div.smalllisp {margin-left: 3.2em} 41kbd {font-style:oblique} 42pre.display {font-family: inherit} 43pre.format {font-family: inherit} 44pre.menu-comment {font-family: serif} 45pre.menu-preformatted {font-family: serif} 46pre.smalldisplay {font-family: inherit; font-size: smaller} 47pre.smallexample {font-size: smaller} 48pre.smallformat {font-family: inherit; font-size: smaller} 49pre.smalllisp {font-size: smaller} 50span.nocodebreak {white-space:nowrap} 51span.nolinebreak {white-space:nowrap} 52span.roman {font-family:serif; font-weight:normal} 53span.sansserif {font-family:sans-serif; font-weight:normal} 54ul.no-bullet {list-style: none} 55--> 56</style> 57 58 59</head> 60 61<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> 62<a name="Enumerations"></a> 63<div class="header"> 64<p> 65Next: <a href="Structures.html#Structures" accesskey="n" rel="next">Structures</a>, Previous: <a href="Strings.html#Strings" accesskey="p" rel="previous">Strings</a>, Up: <a href="Types.html#Types" accesskey="u" rel="up">Types</a> [<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> 66</div> 67<hr> 68<a name="Enumerations-1"></a> 69<h3 class="section">5.7 Enumerations</h3> 70 71<p>Enumerations are defined with the ‘<samp>e</samp>’ type descriptor. 72</p> 73<p>The source line below declares an enumeration type at file scope. 74The type definition is located after the <code>N_RBRAC</code> that marks the end of 75the previous procedure’s block scope, and before the <code>N_FUN</code> that marks 76the beginning of the next procedure’s block scope. Therefore it does not 77describe a block local symbol, but a file local one. 78</p> 79<p>The source line: 80</p> 81<div class="example"> 82<pre class="example">enum e_places {first,second=3,last}; 83</pre></div> 84 85<p>generates the following stab: 86</p> 87<div class="example"> 88<pre class="example">.stabs "e_places:T22=efirst:0,second:3,last:4,;",128,0,0,0 89</pre></div> 90 91<p>The symbol descriptor (‘<samp>T</samp>’) says that the stab describes a 92structure, enumeration, or union tag. The type descriptor ‘<samp>e</samp>’, 93following the ‘<samp>22=</samp>’ of the type definition narrows it down to an 94enumeration type. Following the ‘<samp>e</samp>’ is a list of the elements of 95the enumeration. The format is ‘<samp><var>name</var>:<var>value</var>,</samp>’. The 96list of elements ends with ‘<samp>;</samp>’. The fact that <var>value</var> is 97specified as an integer can cause problems if the value is large. GCC 982.5.2 tries to output it in octal in that case with a leading zero, 99which is probably a good thing, although GDB 4.11 supports octal only in 100cases where decimal is perfectly good. Negative decimal values are 101supported by both GDB and dbx. 102</p> 103<p>There is no standard way to specify the size of an enumeration type; it 104is determined by the architecture (normally all enumerations types are 10532 bits). Type attributes can be used to specify an enumeration type of 106another size for debuggers which support them; see <a href="String-Field.html#String-Field">String Field</a>. 107</p> 108<p>Enumeration types are unusual in that they define symbols for the 109enumeration values (<code>first</code>, <code>second</code>, and <code>third</code> in the 110above example), and even though these symbols are visible in the file as 111a whole (rather than being in a more local namespace like structure 112member names), they are defined in the type definition for the 113enumeration type rather than each having their own symbol. In order to 114be fast, GDB will only get symbols from such types (in its initial scan 115of the stabs) if the type is the first thing defined after a ‘<samp>T</samp>’ or 116‘<samp>t</samp>’ symbol descriptor (the above example fulfills this 117requirement). If the type does not have a name, the compiler should 118emit it in a nameless stab (see <a href="String-Field.html#String-Field">String Field</a>); GCC does this. 119</p> 120<hr> 121<div class="header"> 122<p> 123Next: <a href="Structures.html#Structures" accesskey="n" rel="next">Structures</a>, Previous: <a href="Strings.html#Strings" accesskey="p" rel="previous">Strings</a>, Up: <a href="Types.html#Types" accesskey="u" rel="up">Types</a> [<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> 124</div> 125 126 127 128</body> 129</html> 130