comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
To: <comp.lang.ada@ada.eu.org>
Cc: <Vincent.Smeets@CCI.Sema.de>, <lutz@iks-jena.de>, <byhoe@greenlime.com>
Subject: Re: Size and pack
Date: Thu, 11 Oct 2001 06:18:20 -0500
Date: 2001-10-11T06:18:20-05:00	[thread overview]
Message-ID: <mailman.1002799098.8597.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: slrn9sasi6.hv.lutz@taranis.iks-jena.de


----- Original Message ----- 
From: "Lutz Donnerhacke" <lutz@iks-jena.de>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: October 11, 2001 5:19 AM
Subject: Re: Size and pack


> * Vincent Smeets wrote:
> >Adrian Hoe wrote:
> >>    type Rx_Header_Data is
> >>       record
> >>          Start_Byte   : Character := Latin_1.STX;
> >>          Splitter     : Character;
> >>          Command_Byte : Character;
> >>          Pad_Byte_1   : Character;
> >>          Pad_Byte_2   : Character;
> >>          Log_Num      : Interfaces.C.Long;
> >>          End_Byte     : Character := Latin_1.ETX;
> >>          LRC          : Character;
> >>       end record;
> >
> >Just an other view and a question to CLA,
> >
> >If you read and write this record thrue a stream, will you then get the
> >correct byte layout (with Log_Num at an odd byte)?
> 
> I do not see a reason for expecting it. The Implementation may choose to
> start with a type marker and than dumps the current memory area.
>
The above answer is completely wrong.

The language standard is very clear about the behavior of stream
attributes.

Whether this type is written with 'Outpuit or 'Write, there will
be exactly eleven stream elements written to the stream.  Since this is
not a tagged type, there is no "type marker" to write.  Furthermore,
the behavior of 'Output and 'Write for this type is unaffected by
how the compiler chooses to lay out the record in memory -- whether
11 bytes or 14 bytes, or some other size, or even if the compiler should
choose a different order in which to lay out the components.  To say
"then dumps the current memory area" is misleading at best.

If this _were_ a tagged type, then the behavior of 'Write would be
exactly as described above, but 'Output would precede the data with
the External_Tag of the type.  Since an External_Tag is a string, the
stream representaion of an External_Tag is first a Standard.Integer
containing the length of the string, followed by the characters of the
string.

Furthermore, this behavior is unaffected by any representation
clause or Pragma Pack.

LRM 13.13.2 describes this behavior in detail.
_______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada.eu.org
> http://ada.eu.org/mailman/listinfo/comp.lang.ada
> 




  reply	other threads:[~2001-10-11 11:18 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-10  8:05 Size and pack Adrian Hoe
2001-10-10  8:59 ` Alfred Hilscher
2001-10-10  9:50   ` John McCabe
2001-10-11  6:36     ` Adrian Hoe
2001-10-11  8:55       ` John McCabe
2001-10-31  1:53         ` Robert Dewar
2001-10-31  1:50     ` Robert Dewar
2001-10-31  9:17       ` John McCabe
2001-10-31 11:58       ` Jeff Creem
2001-11-01  1:58         ` Adrian Hoe
2001-11-01  2:34           ` Jeff Creem
2001-11-01 14:58             ` Marin David Condic
2001-11-01  3:53           ` Matthew Heaney
2001-11-01 18:37             ` Jeff Creem
2001-11-02  3:39               ` Robert Dewar
2001-11-01  3:45         ` Jeffrey Carter
2001-11-01  6:00         ` Robert Dewar
2001-10-10  9:24 ` Pi
2001-10-10  9:27 ` Lutz Donnerhacke
2001-10-11  6:24   ` Adrian Hoe
2001-10-11  8:58     ` John McCabe
2001-10-11 13:20       ` Mark Johnson
2001-10-11 16:23         ` John McCabe
2001-10-11 16:00           ` Pat Rogers
2001-10-12  8:37             ` John McCabe
2001-10-28  1:30         ` Robert Dewar
2001-10-11  9:30     ` Lutz Donnerhacke
2001-10-11 10:12 ` Vincent Smeets
2001-10-11 10:19   ` Lutz Donnerhacke
2001-10-11 11:18     ` David C. Hoos, Sr. [this message]
2001-10-11 12:06       ` Lutz Donnerhacke
2001-10-11 13:49 ` Ted Dennison
2001-10-26  4:00 ` Smark
2001-10-26  6:14   ` tmoran
2001-10-26 17:51     ` Smark
2001-10-26 23:21       ` Jeffrey Carter
2001-10-26 23:39       ` tmoran
2001-10-29  1:01         ` Adrian Hoe
2001-10-29  2:21           ` tmoran
2001-10-29 10:42             ` Adrian Hoe
2001-10-29 23:15               ` tmoran
2001-10-29  9:52         ` Lutz Donnerhacke
2001-10-29 10:29           ` Larry Kilgallen
2001-10-29 10:50             ` Lutz Donnerhacke
2001-10-29 11:12               ` Larry Kilgallen
2001-10-31  2:02                 ` Robert Dewar
2001-10-31  2:00               ` Robert Dewar
2001-10-31  2:51                 ` Larry Kilgallen
2001-10-31  1:59           ` Robert Dewar
2001-10-31  1:57       ` Robert Dewar
2001-10-31  1:55   ` Robert Dewar
replies disabled

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