comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.tsoh+bauhaus@maps.futureapps.de>
Subject: Re: pragma Pack does not work on GNAT 5.01a for Redhat Linux.
Date: Tue, 19 Jun 2007 16:02:13 +0200
Date: 2007-06-19T16:02:11+02:00	[thread overview]
Message-ID: <1182261733.7759.26.camel@kartoffel> (raw)
In-Reply-To: <1182259013.590515.118310@g4g2000hsf.googlegroups.com>

On Tue, 2007-06-19 at 06:16 -0700, petter_fryklund@hotmail.com wrote:
> 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);
...
> and similar. Why is pragma Pack ignored?

I don't think pragma Pack is ignored, there are "should"s in the RM
and then alignment. You might need a rep spec, though. Does this work?

   -- assume word size of 32 bits, 4 bytes
   wordsize: constant := 4;

   for Something use record
      A  at 0*wordsize range 0 .. 15;
      B  at 0*wordsize range 16 .. 23;
      C  at 0*wordsize range 24 .. 31;
      D  at 3*wordsize range 0 .. 7;
      E  at 1*wordsize range 0 .. 31;
      F  at 2*wordsize range 0 .. 31;
   end record;

   for Something'Size use 104;





  reply	other threads:[~2007-06-19 14:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-19 13:16 pragma Pack does not work on GNAT 5.01a for Redhat Linux petter_fryklund
2007-06-19 14:02 ` Georg Bauhaus [this message]
2007-06-19 14:15   ` petter_fryklund
2007-06-19 16:16 ` Jeffrey R. Carter
2007-06-19 16:23 ` Adam Beneschan
2007-06-20 15:51 ` Bob Spooner
2007-06-20 16:35   ` Adam Beneschan
2007-06-20 20:50   ` Simon Wright
2007-06-21 14:50     ` Bob Spooner
2007-06-22  5:20       ` Simon Wright
2007-06-29 10:21         ` Ole-Hjalmar Kristensen
2007-07-01 10:57           ` Simon Wright
2007-08-07 10:51             ` Ole-Hjalmar Kristensen
2007-08-10 20:36               ` Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox