comp.lang.ada
 help / color / mirror / Atom feed
From: "Hibou57 (Yannick Duchêne)" <yannick_duchene@yahoo.fr>
Subject: Re: Record representation : components order
Date: Sat, 4 Jul 2009 20:14:28 -0700 (PDT)
Date: 2009-07-04T20:14:28-07:00	[thread overview]
Message-ID: <fe5c021f-bb6a-466f-b5ec-00ceb94661ae@32g2000yqj.googlegroups.com> (raw)
In-Reply-To: 908a786e-214e-436f-868b-c0ead259fcc5@r33g2000yqn.googlegroups.com

Well, I've found an answer, buit this still leave me with a doubt. The
answer first, and the doubt next.

An Ada-Auth discussion with a guy who has forgotten to apply pragma
Convention (C, ...) to the type of the member of a record (not exactly
the subject, while interesting), ends with these words :

http://www.ada-auth.org/cgi-bin/cvsweb.cgi/acs/ac-00023.txt?rev=1.1
says (at the end):
> Now when laying out type Time_Type, it uses textual order for
> the components (this is required by convention C).

“ required by convention C ” : this is what one would expect indeed,
as I did, without beeing sure. But is it stated in the RM ? Annex B.1
does not say such a thing. With the guy (the one who opended the
thread), I agree than some more extensive wording would be required to
fullfill the wish that it is possible to do things in Ada without
relying on a particular compiler's behaviour.

Perhaps it is informally clear to someone, so that is has been left
from the standard (when a thing is obvious to someone, it is easy to
forget to point it).

An other document now, from AdaPower (for a change):
http://www.adapower.com/index.php?Command=Class&ClassID=Advanced&CID=228
says (at the opening):
> pragma Convention(Convention => C) (Christopher Green)
>
> What exactly does "pragma Convention(Convention => C)" do when
> applied to a record type?
>
> It means that record types will be laid out the way C expects them
> to be, whatever that is.
>
> C preserves the order of members within a struct and inserts padding
> so that members will be aligned on the machine-dependent proper
> address boundary for their type.

“ C preserves the order of members within a struct ”, yes that's true,
C do that, but no where a document state what exactly the pragma
Convention for a specific language means independently of a particular
compiler.

Finally, perhaps an annex document would help peoples to feel relieved

This will benefit from beeing more officialy formalized. Putting it in
the core standard wording may be too much, but in an annex, this would
be ok.

What are peoples here think about it ?

N.B. pragma Convention is required when the C specs make use of some
type whose size depends on some configuration. This is not convenient
to use “ at range ” in this case. This is the reason of this thread.



  reply	other threads:[~2009-07-05  3:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-04 21:08 Record representation : components order Hibou57 (Yannick Duchêne)
2009-07-05  3:14 ` Hibou57 (Yannick Duchêne) [this message]
2009-07-05 10:16   ` sjw
2009-07-06  7:33     ` Stephen Leake
2009-07-07 19:37       ` sjw
2009-07-09  9:28         ` Stephen Leake
2009-07-09 19:16           ` sjw
2009-07-10  5:26             ` Stephen Leake
2009-07-06  7:29   ` Stephen Leake
2009-07-06  8:07   ` Jean-Pierre Rosen
2009-07-05 14:10 ` Stephen Leake
2009-07-06  2:57   ` Hibou57 (Yannick Duchêne)
2009-07-06  8:27     ` Jacob Sparre Andersen
replies disabled

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