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,e5140c483354bfcc X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Marc A. Criley" Newsgroups: comp.lang.ada Subject: Re: What is correct way to pack records Date: Thu, 18 Nov 2004 11:04:23 -0600 Message-ID: <30430rF2qcqp0U1@uni-berlin.de> References: <3fc90377.0411171620.7a3bcfd9@posting.google.com> X-Trace: news.uni-berlin.de JqgtrsipSV9284epbswk0A6fU1vcrWQunKjLYsEYhnqLTOPYS+ X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Xref: g2news1.google.com comp.lang.ada:6273 Date: 2004-11-18T11:04:23-06:00 List-Id: "Warren O. Merrill" wrote: > I want my record structures to byte align (for compatibility with > existing files). I know about using the record representation clause > to lay them out. I have a LOT of these to do and just wondering if > any of the pragmas would be guaranteed to byte align my fields but NOT > change the order of the fields to do it (NOTE THAT IS IMPORTANT!!!!!). > > So instead of: > > type MyRec is record > Fld1 : character; > Fld2 : character; > Fld3 : character; > end record; > > for MyRec use record > Fld1 at 0 range 0 .. 7; > Fld2 at 1 range 0 .. 7; > Fld3 at 2 range 0 .. 7; > end record; > > is there a pragma (or other method) that will do the same thing > GUARANTEED not to change the field order to accomplish the packing > without having to write all these record representation clauses? Yes. Though it carries some baggage that may or may not matter to you. pragma Convention(C, MyRec); pragma Convention with the C convention-identifier will ensure that record layout corresponds to that used for a comparable C construct--meaning that it won't change the order, and the fields will occupy the same size, alignment, and offsets as if they were declared using comparable C definitions. Note that pad bytes may be inserted to maintain C-conformant field alignments. If you choose to do this, you should verify that the record layout conforms to the file record format that you'll be reading. Marc A. Criley McKae Technologies www.mckae.com