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 X-Received: by 10.13.210.69 with SMTP id u66mr933052ywd.20.1489879441119; Sat, 18 Mar 2017 16:24:01 -0700 (PDT) X-Received: by 10.157.59.229 with SMTP id k92mr2324389otc.9.1489879440959; Sat, 18 Mar 2017 16:24:00 -0700 (PDT) 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.glorb.com!n21no1138803qta.1!news-out.google.com!w25ni1632qtc.0!nntp.google.com!n21no1138799qta.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 18 Mar 2017 16:24:00 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=118.209.178.48; posting-account=l8GBMwoAAADCbqdOJSbg4dBRqkD14dJd NNTP-Posting-Host: 118.209.178.48 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <403f77a2-992e-45b1-8f5d-a97143783130@googlegroups.com> Subject: Re: Interfaces.C questions From: Leo Brewin Injection-Date: Sat, 18 Mar 2017 23:24:01 +0000 Content-Type: text/plain; charset=UTF-8 Xref: news.eternal-september.org comp.lang.ada:46420 Date: 2017-03-18T16:24:00-07:00 List-Id: Hi Frank, I'd be really interested to see a minimal working example once you've got it running. I'd like to be able to use GSL in my own codes. Cheers, Leo On Saturday, March 18, 2017 at 8:12:28 AM UTC+11, hreba wrote: > 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