From: Simon Wright <simon@pushface.org>
Subject: Re: Sending Variable Length Messages with GNAT.Sockets
Date: Tue, 10 May 2005 21:34:40 +0100
Date: 2005-05-10T21:34:40+01:00 [thread overview]
Message-ID: <m2hdhaom5b.fsf@grendel.local> (raw)
In-Reply-To: m2ll6onrb1.fsf@grendel.local
Simon Wright <simon@pushface.org> writes:
> declare
> Readable : my_array_type (1 .. number_of_array_elements);
> begin
> my_array_type'Read (str, Readable);
I forgot to say, you need to be careful about the components of
records if you're going to let the compiler use the default
'Read/'Write.
If the C side says
struct rec {
char flag;
int count;
};
there will typically be 3 bytes of padding between flag & count, for 8
bytes on the wire.
If the Ada side says
type Rec is record
Flag : Interfaces.Unsigned_8;
Count : Interfaces.Integer_32;
end record;
pragma Convention (C, Rec);
the 'Write will output *5* bytes; but an unchecked conversion to
Stream_Element_Array (1 .. 8) will succeed & do The Right Thing
(endianness permitting).
next prev parent reply other threads:[~2005-05-10 20:34 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-09 10:11 Sending Variable Length Messages with GNAT.Sockets markp
2005-05-09 10:39 ` Adrien Plisson
2005-05-09 11:19 ` markp
2005-05-09 11:50 ` Adrien Plisson
2005-05-09 14:30 ` John B. Matthews
2005-05-09 14:51 ` markp
2005-05-09 18:49 ` Adrien Plisson
2005-05-09 19:16 ` Simon Wright
2005-05-10 15:08 ` markp
2005-05-10 20:34 ` Simon Wright [this message]
2005-05-11 13:19 ` Marc A. Criley
2005-05-11 17:14 ` tmoran
2005-05-11 21:05 ` Simon Wright
2005-05-12 10:24 ` Jacob Sparre Andersen
2005-05-14 11:12 ` Simon Wright
2005-05-09 11:19 ` Jeff C
2005-05-09 11:35 ` markp
2005-05-09 11:57 ` Adrien Plisson
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox