Enumerations.html 6.3 KB

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