help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <>
Subject: Re: gnat -xdr flag confusion.
Date: Tue, 4 Jul 2023 13:39:29 +0200	[thread overview]
Message-ID: <u810dh$12i2$> (raw)
In-Reply-To: <u80tsr$33eu$>

On 2023-07-04 12:56, magardner2010 wrote:

> However, if the ada code encodes the object with 'write, then it creates 
> something about 4 bytes too short, and if I use 'output, it is parsed as 
> starting with family_type 256, which is not a member of the enum. Given 
> that the gnat documentation for the -xdr flag is literally two lines, I 
> don't really know where to look for more information on what I'm doing 
> wrong.

You never defined the protocol and implemented it in the first place. 
You used some code generation tools which, if ever worked, will bite you 
in the end.

To summarize the problem. The stream attribute 'Write writes the 
constrained object. 'Output adds the constraints. Ada is capable to have 
variable length records. C cannot do this. In short, it means that XDR's 
discriminated union can be mapped onto Ada's variant record with no 
default discriminant, but it cannot be directly mapped onto C's union. I 
presume that GNAT implements XDR correctly and the C side does not cope.

Which is one of thousand reasons not to implement a communication 
protocol by deriving representation from some language objects. Cutting 
corners will not help you.

Define the (application level [*]) protocol. Implement it in Ada. 
Implement it in C. Done.

*  XDR or ASN.1 or whatever are not application level!

Dmitry A. Kazakov

  reply	other threads:[~2023-07-04 11:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-04 10:56 gnat -xdr flag confusion magardner2010
2023-07-04 11:39 ` Dmitry A. Kazakov [this message]
2023-07-06 17:32   ` magardner2010
replies disabled

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