comp.lang.ada
 help / color / mirror / Atom feed
From: Leo Brewin <leo.brewin@internode.on.net>
Subject: Re: Interfaces.C questions
Date: Sat, 18 Mar 2017 16:24:00 -0700 (PDT)
Date: 2017-03-18T16:24:00-07:00	[thread overview]
Message-ID: <403f77a2-992e-45b1-8f5d-a97143783130@googlegroups.com> (raw)
In-Reply-To: <ej31ppF6c01U1@mid.individual.net>

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

  parent reply	other threads:[~2017-03-18 23:24 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-17 21:12 Interfaces.C questions hreba
2017-03-17 21:57 ` Niklas Holsti
2017-03-17 22:14 ` Jeffrey R. Carter
2017-03-17 22:24 ` Dmitry A. Kazakov
2017-03-21 21:08   ` Michael B.
2017-03-21 21:28     ` Dmitry A. Kazakov
2017-03-21 21:31     ` Simon Wright
2017-03-22 20:35       ` Randy Brukardt
2017-03-18 15:46 ` hreba
2017-03-18 16:26   ` Jeffrey R. Carter
2017-03-18 16:27   ` Jeffrey R. Carter
2017-03-19  7:03   ` Keith Thompson
2017-03-18 23:24 ` Leo Brewin [this message]
2017-03-19 12:17   ` hreba
2017-03-20  9:44     ` Leo Brewin
2017-03-19  7:00 ` Keith Thompson
2017-03-19 12:05 ` Per Sandberg
2017-03-19 18:39 ` hreba
2017-03-19 19:22   ` Simon Wright
2017-03-19 19:49     ` hreba
2017-03-19 23:53       ` Simon Wright
2017-03-20 11:12         ` hreba
2017-03-20 14:04         ` hreba
2017-03-22 11:21           ` hreba
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox