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=3.8 required=5.0 tests=BAYES_00,INVALID_MSGID, RATWARE_MS_HASH,RATWARE_OUTLOOK_NONAME autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b93f800319d6e6e7,start X-Google-Attributes: gid103376,public From: "kgamble" Subject: Aligning record components Date: 1997/07/08 Message-ID: <01bc8b3a$d9161b80$7175b89e@Ken'slaptop.ssd.loral.com>#1/1 X-Deja-AN: 255377562 Organization: Space Software Systems Newsgroups: comp.lang.ada Date: 1997-07-08T00:00:00+00:00 List-Id: I am porting Ada code from a 16-bit machine to a PC. The original code had record structures that had components aligned on 16-bit boundaries. The components were 16 and 32 bit integers and 32 bit floats. I need to maintain the exact alignments on the new PC target. There does not appear to be a way to do this using the GNAT compiler without resorting to record representation clauses. I understand the benefits of using such clauses, but the scope of the work to create thousands of these component clauses is significant, so I am looking for a work around. If I could force 2-byte alignments, then my problem would be solved. However, GNAT only allows 4-byte alignments. In the following data structure I would need to see components at positions at (0,2,6,10,14). What GNAT gives is (0,2,8,12,16), or by using pragma pack (0,2,6,12,16). It is interesting that the pack version does align 32-bit integers correctly, but has no affect on 32-bit floats. type rec_type is record I16: Integer_16; I32: Integer_32; J32: Integer_32; f: float_32 ; H: float_32; end record; I understand that relying on implicit characteristics of a compiler is not good for portability. But a required goal in the port is to make minimal changes to the original source code when doing the port. Fixing the original source code to use representation clauses is not possible at this time. I do not know why GNAT does not allow 2-byte alignments. There are still plenty of 16-bit target machines that Ada supports.