comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: C array to ada record interface
Date: Tue, 27 Jul 2004 21:04:42 GMT
Date: 2004-07-27T21:04:42+00:00	[thread overview]
Message-ID: <KrzNc.180996$JR4.87585@attbi_s54> (raw)
In-Reply-To: 87d62imomb.fsf@insalien.org

>   type B_Ptr is access all B;
>   pragma Convention (C, B_Ptr);
> ...
>       function To_Address is new Ada.Unchecked_Conversion
>          (Source => B_Ptr, Target => System.Address);

  Interesting possible problem:  One of the compilers I use rejected
the Unchecked_Conversion because its System.Address is not the same
size as B_Ptr.  So I dropped the Unchecked programming and used instead

    package B_Ptr_Conversion is new System.Address_To_Access_Conversions(B);
    subtype B_Ptr is B_Ptr_Conversion.Object_Pointer;
which works on three different compilers.  But neither

    pragma Convention (C, B_Ptr);
nor
    pragma Convention (C, B_Ptr_Conversion.Object_Pointer);
is then legal.

The program works without the pragma Convention on all three Ada compilers
I tried, but it's not clear to me that's guaranteed to be OK, and if some
system does need the pragma, is there a compiler-agnostic way to solve
this problem?

(Neither is    pragma Convention (C, Array_With_Known_Length);
legal but that seems even less likely to be necessary.)



  reply	other threads:[~2004-07-27 21:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-14 23:17 C array to ada record interface Francisco Javier Loma Daza
2004-07-15  0:36 ` Brian May
2004-07-15  1:23 ` Jeffrey Carter
2004-07-22 18:02   ` Francisco Javier Loma Daza
2004-07-24 18:48     ` Ludovic Brenta
2004-07-25 17:26       ` Francisco Javier Loma Daza
2004-07-25 19:28       ` tmoran
2004-07-26 21:42         ` Ludovic Brenta
2004-07-27 21:04           ` tmoran [this message]
2004-07-27 22:15             ` Martin Dowie
2004-07-28  2:42             ` Robert I. Eachus
2004-07-29  5:56               ` tmoran
2004-07-29 19:58                 ` Robert I. Eachus
replies disabled

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