comp.lang.ada
 help / color / mirror / Atom feed
* Re: Help - Call C function (with out parameter) from ADA95
  1996-10-11  0:00 Help - Call C function (with out parameter) from ADA95 Mikael Espersen
@ 1996-10-11  0:00 ` Robert Dewar
  1996-10-11  0:00 ` David Shochat
  1 sibling, 0 replies; 3+ messages in thread
From: Robert Dewar @ 1996-10-11  0:00 UTC (permalink / raw)



Mikael asks

"Does anyone know how to call a C function with out a parameter from ADA95.
As far as I know ADA is only allowing in parameters to functions. The C
function also has a return value so I can't declare as a procedure. Any
help would be appreciated Thanks in advance."

You can model it as an access parameter on the Ada side, either using an
explicit access type, or, if null is not a possible value, using an 
access parameter.

Another possibility if you are using GNAT version 3.07 or later, is to use
the pragma Import_Valued_Procedure, which is exactly intended for this case,
and allows a subprogram that is externally a function to be modeled as a
procedure with an extra out parameter.

P.S. The 3.07 sources are now frozen, so the public release of 3.07 for
at least some targets should occur fairly soon now. Note that 3.06 was
skipped (it was the version on an SGI prerelease).





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Help - Call C function (with out parameter) from ADA95
  1996-10-11  0:00 Help - Call C function (with out parameter) from ADA95 Mikael Espersen
  1996-10-11  0:00 ` Robert Dewar
@ 1996-10-11  0:00 ` David Shochat
  1 sibling, 0 replies; 3+ messages in thread
From: David Shochat @ 1996-10-11  0:00 UTC (permalink / raw)



Mikael Espersen wrote:
> 
> Hi,
> 
> Does anyone know how to call a C function with out a parameter from ADA95.
> As far as I know ADA is only allowing in parameters to functions. The C
> function also has a return value so I can't declare as a procedure. Any
> help would be appreciated Thanks in advance.
> 
> Eks. (C program code)
> 
> int InitArray(char* arr);

Seems to me that would just be:

function InitArray (Arr : in Interfaces.C.Strings.chars_ptr) return
Interfaces.C.int;

C doesn't have "out" parameters. In C everything is passed by value. One
gets the effect of call by reference by explicitly passing a pointer (by
value). Your InitArray() looks kind of dangerous since it doesn't have a
parameter to limit the number of characters it writes.
-- David




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Help - Call C function (with out parameter) from ADA95
@ 1996-10-11  0:00 Mikael Espersen
  1996-10-11  0:00 ` Robert Dewar
  1996-10-11  0:00 ` David Shochat
  0 siblings, 2 replies; 3+ messages in thread
From: Mikael Espersen @ 1996-10-11  0:00 UTC (permalink / raw)



Hi,

Does anyone know how to call a C function with out a parameter from ADA95.
As far as I know ADA is only allowing in parameters to functions. The C
function also has a return value so I can't declare as a procedure. Any
help would be appreciated Thanks in advance.

Eks. (C program code)

int InitArray(char* arr);




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1996-10-11  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-10-11  0:00 Help - Call C function (with out parameter) from ADA95 Mikael Espersen
1996-10-11  0:00 ` Robert Dewar
1996-10-11  0:00 ` David Shochat

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