comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: pragma Pack does not work on GNAT 5.01a for Redhat Linux.
Date: Tue, 19 Jun 2007 09:23:17 -0700
Date: 2007-06-19T09:23:17-07:00	[thread overview]
Message-ID: <1182270197.106022.112630@q19g2000prn.googlegroups.com> (raw)
In-Reply-To: <1182259013.590515.118310@g4g2000hsf.googlegroups.com>

On Jun 19, 6:16 am, petter_frykl...@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);
>
> 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?

Strange... I get 104 when I try it on Linux.  I could be using a
different version of GNAT, though.

                          -- Adam

package Test109pak is

    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;

    type Packed_16 is new Packed_Bytes (0 .. 1);
    for Packed_16'Size use 16;

    type Packed_32 is new Packed_Bytes (0 .. 3);
    for Packed_32'Size use 32;

    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);

end Test109pak;

with Test109pak;
with Text_IO;
procedure Test109 is
begin
    Text_IO.Put_Line ("Size is " & Integer'Image
(Test109pak.Something'Size));
end Test109;





  parent reply	other threads:[~2007-06-19 16:23 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
2007-06-19 14:15   ` petter_fryklund
2007-06-19 16:16 ` Jeffrey R. Carter
2007-06-19 16:23 ` Adam Beneschan [this message]
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