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,FREEMAIL_FROM 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!feeder.eternal-september.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: hreba Newsgroups: comp.lang.ada Subject: Interfaces.C questions Date: Fri, 17 Mar 2017 22:12:25 +0100 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net tAegl25AJjCTTL6b87QdkgnbNw+AsE9uHjsvvfQEW2qaTu6khB Cancel-Lock: sha1:h3VtqwxYbws2/L5hTqprJCatkOQ= X-Mozilla-News-Host: news://News.Individual.DE:119 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 Xref: news.eternal-september.org comp.lang.ada:46413 Date: 2017-03-17T22:12:25+01:00 List-Id: These are my first steps with Interfaces.C: ---------------------------------------------------------------------- with Interfaces.C; package GSL is package C renames Interfaces.C; type size_t is new C.int; type Real_Function is access function (x: C.double) return C.double; function Bessel_J0 (x: C.double) return C.double; function Integration_QNG (f: Real_Function; a, b, epsabs, epsrel: C.double; result, abserr: out C.double; neval: out size_t) return C.int; private pragma Import (C, Bessel_J0, "gsl_sf_bessel_J0"); pragma Import (C, Integration_QNG, "gsl_integration_qng"); end GSL; ------------------------------------------------------------------------ No problem with function Bessel_J0. But Integration_QNG gets me: gsl.ads:19:07: functions can only have "in" parameters. The C prototype of this function is: int gsl_integration_qng (const gsl function * f , double a , double b , double epsabs , double epsrel , double * result , double * abserr , size t * neval ) So my questions are: 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? 2. On my platform size_t is C.int. How can I define size_t in a platform-independent way? 3. The C function above needs a pointer to a function as parameter. Is my translation to Ada correct? -- Frank Hrebabetzky +49 / 6355 / 989 5070