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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7345e706c651a1a3 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news.glorb.com!news.aset.psu.edu!not-for-mail From: "Bob Spooner" Newsgroups: comp.lang.ada Subject: Re: pragma Pack does not work on GNAT 5.01a for Redhat Linux. Date: Wed, 20 Jun 2007 11:51:27 -0400 Organization: Penn State University, Center for Academic Computing Message-ID: References: <1182259013.590515.118310@g4g2000hsf.googlegroups.com> NNTP-Posting-Host: nat2.arl.psu.edu X-Trace: f04n12.cac.psu.edu 1182354688 48764 128.118.40.77 (20 Jun 2007 15:51:28 GMT) X-Complaints-To: usenet@f04n12.cac.psu.edu NNTP-Posting-Date: Wed, 20 Jun 2007 15:51:28 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138 Xref: g2news1.google.com comp.lang.ada:16274 Date: 2007-06-20T11:51:27-04:00 List-Id: wrote in message news:1182259013.590515.118310@g4g2000hsf.googlegroups.com... > The Size of the following record is 112 on Linux, but 104 on Solaris. > > type Something is record > A : Packed_16; > B : Packed_8; > C : Packed_8; > D : Packed_8; > E : Packed_32; > F : Packed_32; > end record; > pragma Pack (Something); > > Where > > type Packed_Byte is mod 2 **8; > for Packed_Byte'Size use 8; > > type Packed_Bytes is array (Natural range <>) of Packed_Byte; > for Packed_Bytes'Alignment use 1; > for Packed_Bytes'Component_Size use Packed_Byte'Size; > > type Packed_8 is new Packed_Bytes (0 .. 0); > for Packed_8'Size use 8; > > and similar. Why is pragma Pack ignored? > > TIA > /Petter > Are the processors different on the two systems? For some processors, the overhead for retrieving a 32-bit value that is not alligned on an even address or an address divisible by four could be enough higher that the default record layout will be different from what you experienced with Solaris. Then, depending on the interpretation of "storage minimization should be the main criterion when selecting the representation of a composite type" for pragma Pack in the RM, the packed layout may be different as well, since pragmas are only advice to the compiler. If you use a record representation clause, I would expect that if the compiler could not generate code to give you what you asked for, it would generate an error. You can use the 'size attribute to specify the overall record size, but then the compiler is still free to rearange the order of components to optimize storage and retrieval of the record components. For exchanging binary data between heterogeneous systems, my experience has been that record representation clauses are necessary to insure that the data representations are identical. Regards, Bob