comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Should representation clauses be complete for each bit?
Date: Thu, 21 Jul 2011 11:06:28 -0400
Date: 2011-07-21T11:06:28-04:00	[thread overview]
Message-ID: <wccd3h3brm3.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 4e27f4ba$0$6584$9b4e6d93@newsspool3.arcor-online.net

Georg Bauhaus <rm.dash-bauhaus@futureapps.de> writes:

> More specifically, if the original example of "not all bits used and some
> gaps between them" is unusual, is it so
>
> - when mapping to a set of hardware pins, say?

Whenever I see documentation for such things, they have rectangular pictures
showing what every bit means.  They don't have implicit gaps.  If there
are any gaps, they are shown explicitly, as "must be zero" or "reserved
for future hardware extensions" or whatever.

My claim is that the Ada code interfacing to such a thing should be
similarly explicit about the gaps.

Otherwise, you end up with nasty bugs: one compiler just happens to
set the gaps to zero, and you write to a file, and binary comparisons
of those files work.  Then you port to a different compiler, and it
puts arbitrary junk in the gaps.

> - or when "interfacing" to C structs?
>
> For C structs, declaration order seems very convenient, as C keeps
> declaration order.  But C may well introduce gaps between structure
> components whenever its alignment rules requires.  Then I will want
> gaps in Ada, too.  Is a convention pragma sufficient, then?

Right, pragma Convention(C) will properly interface to a C struct,
so long as the Ada record matches the C struct component-for-component,
and you're using a C compiler supported (for interfacing) by the Ada
compiler -- it's the Ada compiler's job to make the layout match
what that particular C compiler does.  And Convention(C) will prevent
reordering of components.

- Bob



  reply	other threads:[~2011-07-21 15:06 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-20 10:34 Should representation clauses be complete for each bit? okellogg
2011-07-20 14:51 ` Robert A Duff
2011-07-20 15:24   ` Georg Bauhaus
2011-07-20 17:28     ` Robert A Duff
2011-07-21  7:37       ` Martin
2011-07-21  8:22         ` Simon Wright
2011-07-21 14:58           ` Robert A Duff
2011-07-23  0:13             ` Randy Brukardt
2011-07-27 14:12               ` okellogg
2011-07-28  0:03                 ` Randy Brukardt
2011-07-21  9:43         ` Georg Bauhaus
2011-07-21 15:06           ` Robert A Duff [this message]
2011-07-31 15:02             ` BrianG
2011-07-21 21:11           ` Brian Drummond
2011-07-21  7:59     ` Stephen Leake
2011-07-20 15:29   ` okellogg
2011-07-20 16:24     ` Dmitry A. Kazakov
2011-07-20 16:58       ` okellogg
2011-07-20 19:38         ` Dmitry A. Kazakov
2011-07-20 17:27     ` Robert A Duff
2011-07-20 19:14       ` okellogg
2011-07-20 20:13         ` J-P. Rosen
2011-07-20 21:23           ` Robert A Duff
2011-07-20 21:21         ` Robert A Duff
2011-07-21  8:02         ` Stephen Leake
2011-07-21  8:00     ` Stephen Leake
2011-07-21  7:36   ` Martin
2011-07-22 23:50   ` Randy Brukardt
2011-07-23  2:16     ` tmoran
2011-07-23 15:12     ` Robert A Duff
2011-07-26 21:10       ` Randy Brukardt
2011-07-23  0:01   ` Randy Brukardt
  -- strict thread matches above, loose matches on Subject: below --
1998-04-17  0:00 Should Representation Clauses " Marin David Condic, 561.796.8997, M/S 731-96
     [not found] <3533C3C5.3F25CB91@cacd.rockwell.com>
1998-04-16  0:00 ` Stephen Leake
replies disabled

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