Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ada > Interfacing to ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 27 Topic 5570 of 5881
Post > Topic >>

Interfacing to C: big structures

by Maciej Sobczak <see.my.homepage@[EMAIL PROTECTED] > Feb 25, 2008 at 01:17 PM

Hi,

Consider the C API that contains some structure S and a couple of
functions that operate on the state that is stored in the Struct. A
typical usage in C might be:

struct S s;

init(&s);
foo(&s);
bar(&s);
baz(&s);

Above, s is created with automatic storage duration.

How to interface to this from Ada? I see two options:

1. Write a simple wrapper that will create S on the heap and use the
pointer everywhere. This is easy, but imposes the use of dynamic
memory, which for some reasons I might want to avoid.
2. Create an Ada array of basic storage units of "appropriate size"
and pass its address to the C functions. The advantage of this
solution is that it does not impose any particular memory management
scheme, but the disadvantage is that it is potentially non-****table
(how to get the "appropriate size"?).

Would you suggest some other solution?

--
Maciej Sobczak * www.msobczak.com * www.inspirel.com
 




 27 Posts in Topic:
Interfacing to C: big structures
Maciej Sobczak <see.my  2008-02-25 13:17:45 
Re: Interfacing to C: big structures
"Randy Brukardt"  2008-02-25 17:26:00 
Re: Interfacing to C: big structures
Robert A Duff <bobduff  2008-02-25 18:43:56 
Re: Interfacing to C: big structures
Stephen Leake <stephen  2008-02-26 08:53:14 
Re: Interfacing to C: big structures
"Randy Brukardt"  2008-02-26 15:12:17 
Re: Interfacing to C: big structures
"Randy Brukardt"  2008-02-25 17:26:00 
Re: Interfacing to C: big structures
"Randy Brukardt"  2008-02-25 17:26:00 
Re: Interfacing to C: big structures
"Steve" <nos  2008-02-25 18:36:35 
Re: Interfacing to C: big structures
"Alex R. Mosteo"  2008-02-26 13:00:28 
Re: Interfacing to C: big structures
Robert A Duff <bobduff  2008-02-26 09:05:48 
Re: Interfacing to C: big structures
"Alex R. Mosteo"  2008-02-26 16:19:45 
Re: Interfacing to C: big structures
Robert A Duff <bobduff  2008-02-26 10:33:15 
Re: Interfacing to C: big structures
"Alex R. Mosteo"  2008-02-26 17:21:42 
Re: Interfacing to C: big structures
Robert A Duff <bobduff  2008-02-26 20:28:48 
Re: Interfacing to C: big structures
David Thompson <dave.t  2008-03-10 01:38:30 
Re: Interfacing to C: big structures
Adam Beneschan <adam@[  2008-02-26 09:35:53 
Re: Interfacing to C: big structures
Simon Wright <simon.j.  2008-02-26 19:47:32 
Re: Interfacing to C: big structures
"Randy Brukardt"  2008-02-26 15:14:36 
Re: Interfacing to C: big structures
Robert A Duff <bobduff  2008-02-26 20:40:09 
Re: Interfacing to C: big structures
Robert A Duff <bobduff  2008-02-26 20:37:17 
Re: Interfacing to C: big structures
Maciej Sobczak <see.my  2008-02-27 05:23:48 
Re: Interfacing to C: big structures
Maciej Sobczak <see.my  2008-02-27 05:49:43 
Re: Interfacing to C: big structures
Adam Beneschan <adam@[  2008-02-27 09:12:06 
Re: Interfacing to C: big structures
Simon Wright <simon.j.  2008-02-27 20:37:58 
Re: Interfacing to C: big structures
"Alex R. Mosteo"  2008-02-28 12:30:26 
Re: Interfacing to C: big structures
Robert A Duff <bobduff  2008-02-28 10:53:21 
Re: Interfacing to C: big structures
"Alex R. Mosteo"  2008-02-29 11:45:32 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Sep 7 7:49:33 CDT 2008.