From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e4d318dc27be1451 X-Google-Attributes: gid103376,public From: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: Pragma pack Date: 1997/03/17 Message-ID: #1/1 X-Deja-AN: 226287924 References: <01IGC5R855Z6001KU2@EMAIL.AZ.HONEYWELL.COM> Organization: New York University Newsgroups: comp.lang.ada Date: 1997-03-17T00:00:00+00:00 List-Id: Matthew Heaney says <> Or, where appropriate, a pragma Convention, which is far more portable. Also, if you want to save space, it is important to pack any individual composite components separately. For example type x is array (0..7) of Boolean; type y is record a,b,c,d : x; end record; pragma pack (y); Here using GNAT, and quite likely with other compilers too, the size of y will be 256 bits. If you want 32 bits, you must also write: pragma pack (x); and it is actually probably this second pack that actually does the job, the pragma pack of y is probably redundant (but certainly harmless!) Note that in some Ada 83 compilers, you could achieve the tight packing simply by saying for y'size use 32; but both Ada 83 AI's and the implementation advice in the Ada 95 RM advise against allowing 'Size to influence internal representations, and GNAT follows this advice, so it will reject this size clause in the absence of a pragma pack for type x. Similarly for x'size use 8 cannot be used to effect the packing of x, either pragma Pack (x) or for x'component_size use 1; is required. Putting both in, as well the size clause, again is probably redundent, but harmless. Over-specification does no harm in the world of rep clause non-portability :-)