comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Interfaces.C questions
Date: Fri, 17 Mar 2017 23:14:11 +0100
Date: 2017-03-17T23:14:11+01:00	[thread overview]
Message-ID: <oahmu7$qi$1@dont-email.me> (raw)
In-Reply-To: <ej31ppF6c01U1@mid.individual.net>

On 03/17/2017 10:12 PM, hreba wrote:
>
> 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?

Ada before Ada 12 only allows "in" parameters for functions. If using such a 
compiler, you'll have to use pointers on the Ada side as well. If you have an 
Ada-12 compiler (currently only GNAT), then functions can have "in out" and 
"out" parameters, which are better for this case.

> 2. On my platform size_t is C.int. How can I define size_t in a
> platform-independent way?

Use Interfaces.C.size_t.

> 3. The C function above needs a pointer to a function as parameter. Is my
> translation to Ada correct?

You should declare that your access type is convention C:

pragma Convention (C, Real_Function);

-- 
Jeff Carter
"Apart from the sanitation, the medicine, education, wine,
public order, irrigation, roads, the fresh water system,
and public health, what have the Romans ever done for us?"
Monty Python's Life of Brian
80

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