comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: Ada Address = C pointer ?
Date: Tue, 30 Oct 2001 19:53:45 GMT
Date: 2001-10-30T19:53:45+00:00	[thread overview]
Message-ID: <dzDD7.91688$gT6.47998125@news1.rdc1.sfba.home.com> (raw)
In-Reply-To: mailman.1004438597.846.comp.lang.ada@ada.eu.org

> Interesting. The code is incompatible with GNAT.
  Of course it is.  The particular Gnat you are using has a System.Address
that only works within a single segment, so it does not include the
segment part.  The ARM suggests System.Address should be private,
presumably to discourage coding that depends on a particular
implementation.

> Ada                C
> --------------------
> Address       * void
> Address       * char
> Null_Address    NULL
>
> GNAT seems to honor these equivalences.  Does Janus?
  (I'm not sure I'd use the word "honor" to describe a particular
implementation artifact. ;)
  I haven't used any Janus compilers on other platforms, so can't answer
for them.  On x86's Janus appears to convert (I haven't experimented with this
since I use Access types) automagically on parameter passing, but I'm sure

  type Address_List is array(1 .. 10) of System.Address;
  X : Address_List;
  procedure Cfunc(X : out Address_List);
  pragma Import(C, Cfunc);
---
  void Cfunc(char **p)

would give unpleasant results.

Do all versions of Gnat on all platforms implement those particular
equivalences?  Do even all other Ada compilers on your current platform
implement them?

> Yes, I know that null = NULL seems an obvious interpretation of
> "C-compatible", but the RM is not known for relying on the obvious.
>
> So, either way (Interfaces.C.Pointers vs.
> System.Address_To_Access_Conversions), _assumptions_ are made (by the
> programmer).
  Can you suggest any other reasonable interpretation besides null = NULL?
Does the RM even suggest that a System.Address has anything to do with
interfacing to other languages?  The RM may not be obvious, but it doesn't
*try* to mislead.

> But I agree a Pointers idiom is a viable, perhaps better, alternative to a
> System one. Perhaps I'll change my code some day.
  In the meantime, put in a comment for future maintainers that
your code assumes a specific Gnat version on a specific platform.
(Having maintained code dependent on a particular, ancient, version of
a compiler, I offer my condolences to those maintainers.)



  reply	other threads:[~2001-10-30 19:53 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-26 18:53 Ada Address = C pointer ? M. A. Alves
2001-10-26 18:09 ` Lutz Donnerhacke
2001-10-26 21:06   ` Florian Weimer
2001-10-26 19:34 ` Mark Johnson
2001-10-26 23:39   ` tmoran
2001-10-29 13:07     ` M. A. Alves
2001-10-29 20:19       ` Matthew Heaney
2001-10-29 23:15         ` tmoran
2001-10-30 10:30           ` M. A. Alves
2001-10-30 19:53             ` tmoran [this message]
2001-10-31 13:01               ` M. A. Alves
2001-10-31 14:44                 ` Marin David Condic
2001-10-30  9:58         ` M. A. Alves
2001-10-30 12:02           ` Lutz Donnerhacke
2001-10-30 12:53             ` M. A. Alves
2001-10-30 12:56               ` Lutz Donnerhacke
2001-10-30 14:26                 ` M. A. Alves
2001-10-30 14:19               ` Matthew Heaney
2001-10-30 14:41                 ` M. A. Alves
2001-10-30 17:10           ` Mark Johnson
2001-10-30 18:01             ` M. A. Alves
2001-10-30 20:23               ` tmoran
2001-10-31 13:13                 ` M. A. Alves
2001-10-30 19:53           ` tmoran
2001-10-29 23:15       ` tmoran
replies disabled

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