Message-ID: <3F04C1B6.9E036018@somewhere.nil> Date: Fri, 04 Jul 2003 01:52:22 +0200 From: Gautier Write-only X-Mailer: Mozilla 4.8 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: data alignment issue References: <00A224F4 DOT 86EC817C DOT 6 AT st DOT fmph DOT uniba DOT sk> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 80.218.92.120 X-Trace: news.swissonline.ch 1057276351 80.218.92.120 (4 Jul 2003 01:52:31 +0200) Lines: 47 X-Complaints-To: abuse AT swissonline DOT ch To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Viktor DOT Stujber AT st DOT fmph DOT uniba DOT sk: > I've noticed that djgpp aligns all members of a structure to 4 bytes. Not necessarily (see below). > --------------------------------------------------------------------- > | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | > ---------------------------------------------------- > | a _ _ _ b b b b c c _ _ | > ---------------------------------------------------- > > this is the layout of this structure in memory: > struct { > BYTE a; > DWORD b; > WORD c; > } with Interfaces; use Interfaces; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; procedure Align is type r1 is record a: Unsigned_8; -- 1 b: Unsigned_32; -- 4 c: Unsigned_16; -- 2 end record; type r2 is record a: Unsigned_8; -- 1 b: Unsigned_32; -- 4 c: Unsigned_16; -- 2 end record; pragma pack(r2); begin Put(r1'size/8); Put(r2'size/8); end; DJGPP takes 10 bytes for r1 (choice) and 7 for r2 (it must, because of "pack"). ________________________________________________________ Gautier -- http://www.mysunrise.ch/users/gdm/gsoft.htm NB: For a direct answer, e-mail address on the Web site!