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-Thread: a07f3367d7,74bc23dcb20218db X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder.news-service.com!feeder.news-service.com!85.214.198.2.MISMATCH!eternal-september.org!.POSTED!not-for-mail From: "Alex R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: How to access this package written in C? Followup-To: comp.lang.ada Date: Tue, 27 Apr 2010 08:52:47 +0200 Organization: A noiseless patient Spider Message-ID: References: <4e9d2aaf-c0a6-4798-b838-8f5b7c4a39d1@k33g2000yqc.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit Injection-Date: Tue, 27 Apr 2010 06:49:27 +0000 (UTC) Injection-Info: news.eternal-september.org; posting-host="w8g++bW4v3KH0+SqtoCNSw"; logging-data="16273"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/E+Kk0ei+JBBcWK+T29lqV" User-Agent: KNode/4.4.2 Cancel-Lock: sha1:JVTqTrBggz6rOnZ95inVOvHE54A= Xref: g2news2.google.com comp.lang.ada:11200 Date: 2010-04-27T08:52:47+02:00 List-Id: Maciej Sobczak wrote: > On 26 Kwi, 21:57, Keith Thompson wrote: > >> But C still requires char* and void* to have the same representation. >> >> But in the Ada RM, I only see char_star in an example: >> >> subtype Char_Star is Char_Ptrs.Pointer; > > I use this: > > subtype Void_Ptr is System.Address; I have sometimes used type Void is null record; pragma Convention (Void, C); type Void_Ptr is access all Void; pragma Convention (Void_Ptr, C); Curious here about any implications of using the different approaches. When doing bindings I tend to avoid 'Access and 'Address whenever possible, though; using in out parameters seems to be sufficient in the 99% of cases. On the one hand I like to remain as high-level as possible; on the other I could see that System.Address leaves less room for compiler fancies... > It works like a charm. Please note that in order to link Ada with C > there is a need for a *pair* of *compatible* compilers - you cannot > compile the Ada part with a random Ada compiler and a C part with a > random C compiler and expect them to work together. There is a lot of > hand-waving in the multilanguage development, which means lots of > under-the-table assumptions can be taken for granted even though they > are not explicitly covered by any of the language standards. > > -- > Maciej Sobczak * http://www.inspirel.com > > YAMI4 - Messaging Solution for Distributed Systems > http://www.inspirel.com/yami4