<html lang="en">
<head>
<title>Structures unions enumerations and bit-fields implementation - Using the GNU Compiler Collection (GCC)</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Using the GNU Compiler Collection (GCC)">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="C-Implementation.html#C-Implementation" title="C Implementation">
<link rel="prev" href="Hints-implementation.html#Hints-implementation" title="Hints implementation">
<link rel="next" href="Qualifiers-implementation.html#Qualifiers-implementation" title="Qualifiers implementation">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
Copyright (C) 1988-2015 Free Software Foundation, Inc.

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 the
Invariant Sections being ``Funding Free Software'', the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
``GNU Free Documentation License''.

(a) The FSF's Front-Cover Text is:

     A GNU Manual

(b) The FSF's Back-Cover Text is:

     You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development.-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<div class="node">
<a name="Structures-unions-enumerations-and-bit-fields-implementation"></a>
<a name="Structures-unions-enumerations-and-bit_002dfields-implementation"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Qualifiers-implementation.html#Qualifiers-implementation">Qualifiers implementation</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Hints-implementation.html#Hints-implementation">Hints implementation</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="C-Implementation.html#C-Implementation">C Implementation</a>
<hr>
</div>

<h3 class="section">4.9 Structures, Unions, Enumerations, and Bit-Fields</h3>

     <ul>
<li><cite>A member of a union object is accessed using a member of a
different type (C90 6.3.2.3).</cite>

     <p>The relevant bytes of the representation of the object are treated as
an object of the type used for the access.  See <a href="Type_002dpunning.html#Type_002dpunning">Type-punning</a>.  This
may be a trap representation.

     <li><cite>Whether a &ldquo;plain&rdquo; </cite><code>int</code><cite> bit-field is treated as a
</cite><code>signed int</code><cite> bit-field or as an </cite><code>unsigned int</code><cite> bit-field
(C90 6.5.2, C90 6.5.2.1, C99 and C11 6.7.2, C99 and C11 6.7.2.1).</cite>

     <p><a name="index-funsigned_002dbitfields-2862"></a>By default it is treated as <code>signed int</code> but this may be changed
by the <samp><span class="option">-funsigned-bitfields</span></samp> option.

     <li><cite>Allowable bit-field types other than </cite><code>_Bool</code><cite>, </cite><code>signed int</code><cite>,
and </cite><code>unsigned int</code><cite> (C99 and C11 6.7.2.1).</cite>

     <p>Other integer types, such as <code>long int</code>, and enumerated types are
permitted even in strictly conforming mode.

     <li><cite>Whether atomic types are permitted for bit-fields (C11 6.7.2.1).</cite>

     <p>Atomic types are not permitted for bit-fields.

     <li><cite>Whether a bit-field can straddle a storage-unit boundary (C90
6.5.2.1, C99 and C11 6.7.2.1).</cite>

     <p>Determined by ABI.

     <li><cite>The order of allocation of bit-fields within a unit (C90
6.5.2.1, C99 and C11 6.7.2.1).</cite>

     <p>Determined by ABI.

     <li><cite>The alignment of non-bit-field members of structures (C90
6.5.2.1, C99 and C11 6.7.2.1).</cite>

     <p>Determined by ABI.

     <li><cite>The integer type compatible with each enumerated type (C90
6.5.2.2, C99 and C11 6.7.2.2).</cite>

     <p><a name="index-fshort_002denums-2863"></a>Normally, the type is <code>unsigned int</code> if there are no negative
values in the enumeration, otherwise <code>int</code>.  If
<samp><span class="option">-fshort-enums</span></samp> is specified, then if there are negative values
it is the first of <code>signed char</code>, <code>short</code> and <code>int</code>
that can represent all the values, otherwise it is the first of
<code>unsigned char</code>, <code>unsigned short</code> and <code>unsigned int</code>
that can represent all the values. 
<!-- On a few unusual targets with 64-bit int, this doesn't agree with -->
<!-- the code and one of the types accessed via mode attributes (which -->
<!-- are not currently considered extended integer types) may be used. -->
<!-- If these types are made extended integer types, it would still be -->
<!-- the case that -fshort-enums stops the implementation from -->
<!-- conforming to C90 on those targets. -->

     <p>On some targets, <samp><span class="option">-fshort-enums</span></samp> is the default; this is
determined by the ABI.

</ul>

 </body></html>