comp.lang.ada
 help / color / mirror / Atom feed
* Non byte-aligned components in GNAT rejected
@ 2002-12-11 18:32 Marc A. Criley
  2002-12-11 19:28 ` Stephen Leake
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Marc A. Criley @ 2002-12-11 18:32 UTC (permalink / raw)


(This is one of those situations where I wish I had the scratch to be an ACT
supported customer.)

I'm in the midst of creating type definitions, both scalar and records, for
a thoroughly bit-oriented message set, i.e., absolutely NO regard is paid to
byte boundaries, other than the first and the last bytes of the messages.

GNAT 3.14p on W2K is rejecting one of my rep specs, stating that "large
component must be on byte boundary".

From a compiler implementor perspective, I can see where that limitation is
coming from, but this message format is extracted from a MIL-STD, and this
situation leads me to think that I may not be able to define a "natural"
record specification for messages defined in that standard. Are there any
other representation attributes I ought to try? I've tried 'Alignment and
gotten nowhere with that, so I'm open to suggestion (particularly if they
work on the cut-down package that's attached :-)

If I can't find a way to put these definition together, I'll have to shift
to an "accessor" approach where I just stuff and retrieve bits from an
undifferentiated bit buffer.

Marc A. Criley

-----------------------------------------------------------

package NBA is

   type VMF_Character is new Character range
     Character'Val(0) .. Character'Val(127);
   for VMF_Character'Size use 7;

   type Unit_Name_Type is array (1..64) of VMF_Character;
   for Unit_Name_Type'Component_Size use 7;
   for Unit_Name_Type'Size use 448;

   type Unit_Group_Type is record
      B : Boolean;
      Unit_Name : Unit_Name_Type;
   end record;
   for Unit_Group_Type use record
      B      at 0 range 0 .. 0;
      Unit_Name at 0 range 1 .. 448; -- This is rejected
   end record;

end NBA;



^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: Non byte-aligned components in GNAT rejected
@ 2002-12-12  7:05 Grein, Christoph
  0 siblings, 0 replies; 8+ messages in thread
From: Grein, Christoph @ 2002-12-12  7:05 UTC (permalink / raw)


> -----------------------------------------------------------
> 
> package NBA is
> 
>    type VMF_Character is new Character range
>      Character'Val(0) .. Character'Val(127);
>    for VMF_Character'Size use 7;
> 
>    type Unit_Name_Type is array (1..64) of VMF_Character;
>    for Unit_Name_Type'Component_Size use 7;
>    for Unit_Name_Type'Size use 448;
> 
>    type Unit_Group_Type is record
>       B : Boolean;
>       Unit_Name : Unit_Name_Type;
>    end record;
>    for Unit_Group_Type use record
>       B      at 0 range 0 .. 0;
>       Unit_Name at 0 range 1 .. 448; -- This is rejected
>    end record;
> 
> end NBA;
> _______________________________________________
The following works. You have to split the name so that it has the correct 
boundaries.

package NBA is

   type VMF_Character is new Character range
     Character'Val(0) .. Character'Val(127);
   for VMF_Character'Size use 7;

   type Unit_Name_Type is array (1..56) of VMF_Character;
   for Unit_Name_Type'Component_Size use 7;
   for Unit_Name_Type'Size use 56*7;

   type Unit_Last_Type is array (1..7) of VMF_Character;
   for Unit_Last_Type'Component_Size use 7;
   for Unit_Last_Type'Size use 7*7;

   type Unit_Group_Type is record
      B : Boolean;
      Unit_First: VMF_Character;
      Unit_Name : Unit_Name_Type;
      Unit_Last : Unit_Last_Type;
   end record;
   for Unit_Group_Type use record
      B          at 0 range    0 .. 0;
      Unit_First at 0 range    1 .. 7;          -- together
      Unit_Name  at 1 range    0 ..  56*7 - 1;  -- 64
      Unit_Last  at 1 range 56*7 .. (56+7)*7;   -- characters
   end record;

end NBA;



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2002-12-16 15:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-11 18:32 Non byte-aligned components in GNAT rejected Marc A. Criley
2002-12-11 19:28 ` Stephen Leake
2002-12-12 13:41 ` Marin David Condic
2002-12-12 18:25 ` Peter Richtmyer
2002-12-13 12:39   ` Marc A. Criley
2002-12-13 19:13     ` Peter Richtmyer
2002-12-16 15:51 ` Mark Johnson
  -- strict thread matches above, loose matches on Subject: below --
2002-12-12  7:05 Grein, Christoph

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