comp.lang.ada
 help / color / mirror / Atom feed
From: Jean-Pierre Rosen <rosen@adalog.fr>
Subject: Re: Record representation : components order
Date: Mon, 06 Jul 2009 10:07:10 +0200
Date: 2009-07-06T10:07:10+02:00	[thread overview]
Message-ID: <nbbs2h.dhf.ln@hunter.axlog.fr> (raw)
In-Reply-To: <fe5c021f-bb6a-466f-b5ec-00ceb94661ae@32g2000yqj.googlegroups.com>

Hibou57 (Yannick Duch�ne) a �crit :
> 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.
[...]
>> 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.
> 
Now, since B.1(2) says:
   A pragma Convention is used to specify that an Ada entity should use
   the conventions of another language"
you clearly have to look at the other language's standard to know the
applicable convention. And there, you'll find that C requires to
preserve order. Note that this is hinted by the end of the paragraph:
   For example, �pragma Convention(Fortran, Matrix);� implies that
   Matrix should be represented according to the conventions of the
   supported Fortran implementation, namely column-major order.

Why doesn't the LRM say it clearly? Remember you never interface with
another language, but with another compiler. And if the target C
compiler does not implement the C standard correctly, the Ada compiler
has to match the C compiler, not the C standard.
-- 
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



  parent reply	other threads:[~2009-07-06  8:07 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)
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 [this message]
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