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!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.am4!peer.am4.highwinds-media.com!peer03.fr7!futter-mich.highwinds-media.com!news.highwinds-media.com!fx07.fr7.POSTED!not-for-mail Subject: Re: Interfaces.C questions Newsgroups: comp.lang.ada References: From: Per Sandberg User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID: X-Complaints-To: abuse@usenet.se NNTP-Posting-Date: Sun, 19 Mar 2017 12:05:27 UTC Organization: usenet.se Date: Sun, 19 Mar 2017 13:05:26 +0100 X-Received-Bytes: 2691 X-Received-Body-CRC: 1162118858 X-Original-Bytes: 2640 Xref: news.eternal-september.org comp.lang.ada:46423 Date: 2017-03-19T13:05:26+01:00 List-Id: Why not use the compiler to generate the low-level bindings ?? gcc -fdump-ada-spec It works great takes 95% of the c headers, after generation its usually enough with some simple sed-scripts. That way the binding generation could be 100% automated. Have done that for some fairly large libraries 250 header-files that contains approx 18K ";" and 100K lines including blanks and comments. /Per Den 2017-03-17 kl. 22:12, skrev hreba: > 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? >