comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Interfaces.C questions
Date: Fri, 17 Mar 2017 23:24:42 +0100
Date: 2017-03-17T23:24:42+01:00	[thread overview]
Message-ID: <oahnna$11q$1@gioia.aioe.org> (raw)
In-Reply-To: ej31ppF6c01U1@mid.individual.net

On 2017-03-17 22:12, hreba wrote:
> These are my first steps with Interfaces.C:
>
> ----------------------------------------------------------------------
> with Interfaces.C;
>
> package GSL is
>
>    package C renames Interfaces.C;

Renaming packages is a bad idea. Either use fully-qualified names 
"Interfaces.C.size_t" or else do use-clause "size_t". Renaming lacks 
advantages of either approach inheriting their corresponding disadvantages.

>    type size_t is new C.int;

size_t is defined in Interfaces.C.

>    type Real_Function is access function (x: C.double) return C.double;

pragma Convention (C, Real_Function);

>    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;

     function Integration_QNG
       (f: Real_Function;
        a, b, epsabs, epsrel: Interfaces.C.double;
        result, abserr: access Interfaces.C.double;
        neval: access Interfaces.C.size_t)
       return Interfaces.C.int;

P.S. For convention C assume this:

1. out T, in out T, access T are equivalent

2. in T and access T are equivalent when T is non-scalar (you can pass 
int, array, or record, the compiler will sort that out)

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  parent reply	other threads:[~2017-03-17 22: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 [this message]
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
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