comp.lang.ada
 help / color / mirror / Atom feed
From: robert_s_quinn@yahoo.com (Robert Quinn)
Subject: Re: Is this a GNAT bug???
Date: 30 Apr 2002 09:41:36 -0700
Date: 2002-04-30T16:41:37+00:00	[thread overview]
Message-ID: <db500a4f.0204300841.3f1f15a8@posting.google.com> (raw)
In-Reply-To: 5ee5b646.0204291844.21d7f5f0@posting.google.com

dewar@gnat.com (Robert Dewar) wrote in message 

> So the question is what set of rep clauses is implemented by a given compiler.
> [snip] By staying within this subset you
> achieve greater portability. Once you stray outside this subset, you are 
> writing non-portable code that is implementation dependent. It does not
> mean that your code is nonsense, just that it may not be implemented.

Well that makes sense and I appreciate your reply.  I suppose if I
needed this feature I could work something out with ACT.

I guess the scenario I'm thinking of must not occur too frequently. 
I'll use specific numbers to make the example simple.  Suppose you
have a sequence of 12 bytes 94 bits).  Suppose the first and last byte
are header/tail info, leaving 10 bytes for data.  Suppose 65 bits of
the 10 bytes represent one kind of data, the remaining 13 bits another
kind of data.  It would be nice if you could convert this series of
bytes into a record, for example of the form:

type Message_Type is record
   Header_Data    : Header_Data_Type;
   Data_Element_1 : Data_Element_1_Type;
   Date_Element_2 : Data_Element_2_Type;
   Tail_Data      : Tail_Data_Type;
end record;
for Message_Type use record
   Header_Data at 0 range 0 .. 7;
   Data_Element_1 at 0 range 8 .. 72;
   Data_Element_2 at 0 range 73 .. 85;
   Tail_Data at 0 range 86 .. 93;
end record;

I could convert the sequence of bytes to an access type to this
record.  For example:

type Message_Type_Access is access Message_Type;
function Get_Message_Data is new Unchecked_Conversion
   (SOURCE => System.ADDRESS,
    TARGET => Message_Type_Access);

So the way to handle this same situation with Gnat would be to NOT use
the Unchecked_Conversion, but to make Data_Element_1 larger and just
try to read the bits right out of memory into Data_Element_1.

So reading a sequence of bits >= 65 bits out of memory is just always
going to be more work since you cannot convert it directly into a
type, right?

Ok, I can accept this.  Thanks for your insight, and for the etiquette
pointers on posting.  Please let me know if you have anything to add
to my remarks.

Robert Quinn



  parent reply	other threads:[~2002-04-30 16:41 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-26 16:36 Is this a GNAT bug??? Robert Quinn
2002-04-26 17:48 ` Mark Johnson
2002-04-26 22:20   ` Robert Dewar
2002-04-29 15:45   ` Robert Quinn
2002-04-30  2:44     ` Robert Dewar
2002-04-30 14:15       ` Larry Kilgallen
2002-04-30 16:41       ` Robert Quinn [this message]
2002-04-30 18:20         ` tmoran
2002-05-01  1:31           ` Robert Quinn
2002-05-01 17:08             ` Ted Dennison
2002-05-02  1:55               ` Larry Kilgallen
2002-05-02 14:04                 ` Mark Johnson
2002-05-02 15:25                   ` Larry Kilgallen
2002-04-30 21:55         ` Mark Johnson
2002-05-01 22:59           ` Nick Roberts
2002-05-02 13:56             ` Mark Johnson
2002-05-02 20:19               ` Nick Roberts
2002-05-02 21:55                 ` Mark Johnson
  -- strict thread matches above, loose matches on Subject: below --
2003-09-20 22:50 Is this a gnat bug? Waldek Hebisch
2003-09-20 23:09 ` Ludovic Brenta
2003-09-21  2:37 ` Waldek Hebisch
replies disabled

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