comp.lang.ada
 help / color / mirror / Atom feed
* Converting a C/C++ statement to Ada
@ 2013-02-11 16:48 ldries46
  2013-02-11 17:14 ` Simon Wright
  2013-02-11 21:49 ` Quentin Ochem
  0 siblings, 2 replies; 5+ messages in thread
From: ldries46 @ 2013-02-11 16:48 UTC (permalink / raw)


Can anyone tell me the Ada equivalent for the following C/C++ statement

typedef void (*Apple) (Pair *two_side, pointer_type user_data,  Error_type 
*error);

I am just trying to convert a routine that I can use.

L. Dries 




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

* Re: Converting a C/C++ statement to Ada
  2013-02-11 16:48 Converting a C/C++ statement to Ada ldries46
@ 2013-02-11 17:14 ` Simon Wright
  2013-02-11 18:53   ` Adam Beneschan
  2013-02-11 21:49 ` Quentin Ochem
  1 sibling, 1 reply; 5+ messages in thread
From: Simon Wright @ 2013-02-11 17:14 UTC (permalink / raw)


"ldries46" <bertus.dries@planet.nl> writes:

> Can anyone tell me the Ada equivalent for the following C/C++
> statement
>
> typedef void (*Apple) (Pair *two_side, pointer_type user_data,
> Error_type *error);

I think it's something like

   type Apple is access procedure (two_side : access Pair;
                                   user_data : ?;
                                   error : access Error_type);

but of course the parameters may well not need to be accesses.



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

* Re: Converting a C/C++ statement to Ada
  2013-02-11 17:14 ` Simon Wright
@ 2013-02-11 18:53   ` Adam Beneschan
  2013-02-12  8:53     ` ldries46
  0 siblings, 1 reply; 5+ messages in thread
From: Adam Beneschan @ 2013-02-11 18:53 UTC (permalink / raw)


On Monday, February 11, 2013 9:14:25 AM UTC-8, Simon Wright wrote:
> "ldries46" writes:
> 
> > Can anyone tell me the Ada equivalent for the following C/C++
> > statement
> 
> > typedef void (*Apple) (Pair *two_side, pointer_type user_data,
> > Error_type *error);
> 
> I think it's something like
> 
>    type Apple is access procedure (two_side : access Pair; 
>                                    user_data : ?; 
>                                    error : access Error_type);
> 
> but of course the parameters may well not need to be accesses.

Right.  Unless the C/C++ code actually does something with the pointer values themselves (such as copying two_side or error into some global pointer variable that gets used later), then they probably should not be accesses, but rather just "in Pair", "out Pair", or "in out Pair" (and similarly for Error_type) depending on whether the Pair or its components are read, written, or both.

                             -- Adam




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

* Re: Converting a C/C++ statement to Ada
  2013-02-11 16:48 Converting a C/C++ statement to Ada ldries46
  2013-02-11 17:14 ` Simon Wright
@ 2013-02-11 21:49 ` Quentin Ochem
  1 sibling, 0 replies; 5+ messages in thread
From: Quentin Ochem @ 2013-02-11 21:49 UTC (permalink / raw)


> 
> I am just trying to convert a routine that I can use.
> 

Are you trying to translate code from Ada to C++, or just to interface it?

In the latter case, the gcc switch -fdump-ada-specs does the job for you (http://docs.adacore.com/gnat-unw-docs/html/gnat_ugn_29.html#SEC298)



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

* Re: Converting a C/C++ statement to Ada
  2013-02-11 18:53   ` Adam Beneschan
@ 2013-02-12  8:53     ` ldries46
  0 siblings, 0 replies; 5+ messages in thread
From: ldries46 @ 2013-02-12  8:53 UTC (permalink / raw)


I am happy with this answer, thanks

L. Dries

"Adam Beneschan"  schreef in bericht 
news:eff6a8c1-f589-46b1-9a4e-d4d9a17d9e16@googlegroups.com...

On Monday, February 11, 2013 9:14:25 AM UTC-8, Simon Wright wrote:
> "ldries46" writes:
>
> > Can anyone tell me the Ada equivalent for the following C/C++
> > statement
>
> > typedef void (*Apple) (Pair *two_side, pointer_type user_data,
> > Error_type *error);
>
> I think it's something like
>
>    type Apple is access procedure (two_side : access Pair;
>                                    user_data : ?;
>                                    error : access Error_type);
>
> but of course the parameters may well not need to be accesses.

Right.  Unless the C/C++ code actually does something with the pointer 
values themselves (such as copying two_side or error into some global 
pointer variable that gets used later), then they probably should not be 
accesses, but rather just "in Pair", "out Pair", or "in out Pair" (and 
similarly for Error_type) depending on whether the Pair or its components 
are read, written, or both.

                             -- Adam 




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

end of thread, other threads:[~2013-02-12  8:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-11 16:48 Converting a C/C++ statement to Ada ldries46
2013-02-11 17:14 ` Simon Wright
2013-02-11 18:53   ` Adam Beneschan
2013-02-12  8:53     ` ldries46
2013-02-11 21:49 ` Quentin Ochem

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