From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fc7fc1b95198137d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-30 11:53:46 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newshub2.rdc1.sfba.home.com!news.home.com!news1.rdc1.sfba.home.com.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Ada Address = C pointer ? References: X-Newsreader: Tom's custom newsreader Message-ID: Date: Tue, 30 Oct 2001 19:53:45 GMT NNTP-Posting-Host: 24.7.82.199 X-Complaints-To: abuse@home.net X-Trace: news1.rdc1.sfba.home.com 1004471625 24.7.82.199 (Tue, 30 Oct 2001 11:53:45 PST) NNTP-Posting-Date: Tue, 30 Oct 2001 11:53:45 PST Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: archiver1.google.com comp.lang.ada:15434 Date: 2001-10-30T19:53:45+00:00 List-Id: > 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.)