Changeset c4e3419c


Ignore:
Timestamp:
Feb 15, 2021, 1:52:46 PM (7 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
79debb02
Parents:
17d6214
Message:

formatting, update discussion on unnamed aggregates in C

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/user/user.tex

    r17d6214 rc4e3419c  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Mon Feb 15 09:54:33 2021
    14 %% Update Count     : 4442
     13%% Last Modified On : Mon Feb 15 13:48:53 2021
     14%% Update Count     : 4452
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    12471247\begin{cfa}
    12481248struct Person {                                                         $\C{// aggregate}$
    1249         struct Name {                                                   $\C{// nesting}$
    1250                 char first[20], last[20];
    1251         } name;
    1252         struct Address {                                                $\C{// nesting}$
    1253                 ...
    1254         } address;
     1249        struct Name { char first[20], last[20]; } name $\C{// nesting}$
     1250        struct Address { ... } address                  $\C{// nesting}$
    12551251        int sex;
    12561252};
     
    12711267
    12721268C allows unnamed nested aggregates that open their scope into the containing aggregate.
    1273 However, this feature is only useful for ©union© aggregates.
     1269This feature is used to group fields for attributes and/or with ©union© aggregates.
    12741270\begin{cfa}
    12751271struct S {
     1272        struct { int g,  h; } __attribute__(( aligned(64) ));
     1273        int tag;
    12761274        union {
    1277                 char @c@;   int @i@;   double @d@;
     1275                struct { char c1,  c2; } __attribute__(( aligned(128) ));
     1276                struct { int i1,  i2; };
     1277                struct { double d1,  d2; };
    12781278        };
    1279         int tag;
    1280 } s;
    1281 @s@.tag; @s@.c; @s@.i; @s@.d;                           $\C{// no nested qualification for union fields}$
     1279};
     1280s.g; s.h; s.tag; s.c1; s.c2; s.i1; s.i2; s.d1; s.d2;
    12821281\end{cfa}
    12831282
Note: See TracChangeset for help on using the changeset viewer.