comp.lang.ada
 help / color / mirror / Atom feed
From: "David Botton" <dbotton@hotmail.com>
Subject: Re: Importing a Unix function call
Date: 1998/12/06
Date: 1998-12-06T00:00:00+00:00	[thread overview]
Message-ID: <74e7t5$2deg$1@news.gate.net> (raw)
In-Reply-To: m33e6t7hqk.fsf@mheaney.ni.net

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1177 bytes --]

Since in Ada non-scalar types are passed by reference (ie as pointers) to C
functions you could get rid of the Access type and treat it just like C:

For our case see RM95 B.3 (70) :

� An Ada parameter of an array type with component type T, of any mode, is
passed as a t* argument to a C function, where t is the C type corresponding
to the Ada type T.

function Pipe
    (Files : in File_Descriptor_Array)
return C.Int;
pragma Import (C, Pipe);


declare
  Files  : File_Descriptor_Array;
  Status : constant C.Int := Pipe (Files);
begin


It drives me crazy that many bindings are not written with these rules in
mind making them so much easier to use.


David Botton


Matthew Heaney wrote in message ...
>Steve Crowe <stevecrowe@ndirect.co.uk> writes:
>
>From my man page:
>
>       int pipe(int filedes[2]);
>
>C doesn't have out parameters: only in parameters that point to the
>return data.
>
>How about something like:
>
>with Interfaces.C;  use Interfaces;
>package UNIX is
>
>  type File_Descriptor is new C.int;
>
>  type File_Descriptor_Array is
>     array (Positive range 1 .. 2) of File_Descriptor;
>
>  pragma Convention (C, File_Descriptor_Array);
>







  reply	other threads:[~1998-12-06  0:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-12-04  0:00 Importing a Unix function call Steve Crowe
1998-12-04  0:00 ` dennison
1998-12-04  0:00 ` Larry Kilgallen
1998-12-04  0:00   ` David Botton
1998-12-05  0:00     ` Larry Kilgallen
1998-12-06  0:00 ` Matthew Heaney
1998-12-06  0:00   ` David Botton [this message]
1998-12-06  0:00     ` Matthew Heaney
1998-12-07  0:00       ` dennison
replies disabled

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