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.9 required=5.0 tests=BAYES_00,LOTS_OF_MONEY autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,38ceb882eed41e1e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-31 22:00:06 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: dewar@gnat.com (Robert Dewar) Newsgroups: comp.lang.ada Subject: Re: Size and pack Date: 31 Oct 2001 22:00:05 -0800 Organization: http://groups.google.com/ Message-ID: <5ee5b646.0110312200.75ee9e8c@posting.google.com> References: <9ff447f2.0110100005.2503bb00@posting.google.com> <3BC40DF2.9447F025@icn.siemens.de> <3bc41989.4285341@news.demon.co.uk> <5ee5b646.0110301750.38ba5bfd@posting.google.com> NNTP-Posting-Host: 205.232.38.14 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1004594406 8646 127.0.0.1 (1 Nov 2001 06:00:06 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 1 Nov 2001 06:00:06 GMT Xref: archiver1.google.com comp.lang.ada:15528 Date: 2001-11-01T06:00:06+00:00 List-Id: "Jeff Creem" wrote in message news:... > Not for the record case but for arrays of items that have > been rep spec'ed. > > for example, the code fragment > > type My_Type is range 0 .. 3; > for My_Type'size use 2; > > type My_Array is array (1 .. 4) of My_Type; > pragma Pack (My_Array); -- Without this the following > could fail for My_Array'size use 8; Well yes, but this array has NOT been "rep spec'ed", you did not specify a component size. That's what corresponds to specifying a full record clause. So if you want to control exactly what happens, a better form of the above is: type My_Type is range 0 .. 3; for My_Type'Size use 2; type My_Array is array (1 .. 4) of My_Type; for My_Array'Component_Size use 2; for My_Array'Size use 8; the last clause is redundant, but often useful for documentation emphasis, but most certainly a pragma Pack is redundant in this case. > I *THINK* GNAT does allow it to go through without the > rep spec for several versions now. You think wrong, the size clause alone should NOT change the layout, and in GNAT it will not. Use pack if you just generally want to save space (as in the record case). Use component_Size if you want to precisely control the size of components.