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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Interfaces.C questions Date: Fri, 17 Mar 2017 23:14:11 +0100 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 17 Mar 2017 22:11:19 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="bde789c9a4e0cca2e4fca3b12b661dcf"; logging-data="850"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19bjBQq6MfOv4t/7aQg7bb+qpD0SYZjh5Y=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 In-Reply-To: Cancel-Lock: sha1:mvbhzqNaX9jJOLy2q+CK2jdvQM4= Xref: news.eternal-september.org comp.lang.ada:46415 Date: 2017-03-17T23:14:11+01:00 List-Id: On 03/17/2017 10:12 PM, hreba wrote: > > 1. How do I translate C functions which return non-void and which additionally > use pointers for out parameters? Do I have to use pointers in my Ada program? Ada before Ada 12 only allows "in" parameters for functions. If using such a compiler, you'll have to use pointers on the Ada side as well. If you have an Ada-12 compiler (currently only GNAT), then functions can have "in out" and "out" parameters, which are better for this case. > 2. On my platform size_t is C.int. How can I define size_t in a > platform-independent way? Use Interfaces.C.size_t. > 3. The C function above needs a pointer to a function as parameter. Is my > translation to Ada correct? You should declare that your access type is convention C: pragma Convention (C, Real_Function); -- Jeff Carter "Apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, the fresh water system, and public health, what have the Romans ever done for us?" Monty Python's Life of Brian 80