* Interfacing to C and void*
@ 2006-02-20 15:19 Maciej Sobczak
2006-02-20 18:24 ` Georg Bauhaus
2006-02-20 19:01 ` Martin Krischik
0 siblings, 2 replies; 7+ messages in thread
From: Maciej Sobczak @ 2006-02-20 15:19 UTC (permalink / raw)
Hi,
Suppose I have the following two C functions:
void * factory();
void sink(void *p);
I use them this way:
void *someObject = factor();
sink(someObject);
What is the recommended approach to interfacing to such functions from
Ada? I cannot find anything (in part B of AARM) that would help with
void*. Of course, I could wrap these functions into something that uses
long values (or some other tokens) and appropriate mapping at the level
of the wrapper, but I still hope there is more direct way.
--
Maciej Sobczak : http://www.msobczak.com/
Programming : http://www.msobczak.com/prog/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Interfacing to C and void*
2006-02-20 15:19 Interfacing to C and void* Maciej Sobczak
@ 2006-02-20 18:24 ` Georg Bauhaus
2006-02-20 18:54 ` Jeffrey R. Carter
2006-02-20 19:01 ` Martin Krischik
1 sibling, 1 reply; 7+ messages in thread
From: Georg Bauhaus @ 2006-02-20 18:24 UTC (permalink / raw)
Maciej Sobczak wrote:
> Hi,
>
> Suppose I have the following two C functions:
>
> void * factory();
I have seen System.Address used for this.
-- Georg
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Interfacing to C and void*
2006-02-20 18:24 ` Georg Bauhaus
@ 2006-02-20 18:54 ` Jeffrey R. Carter
0 siblings, 0 replies; 7+ messages in thread
From: Jeffrey R. Carter @ 2006-02-20 18:54 UTC (permalink / raw)
Georg Bauhaus wrote:
> Maciej Sobczak wrote:
>
>>Suppose I have the following two C functions:
>>
>>void * factory();
>
> I have seen System.Address used for this.
Not good practice, since System.Address need not correspond to a C pointer.
Generally, void* is never dereferenced, so any C-convention access type is
suitable. I usually use
type Void_Ptr is access all Integer;
pragma Convention (C, Void_Ptr);
function Factory return Void_Ptr;
pragma Import (C, Factory, "factory");
--
Jeff Carter
"Alms for an ex-leper!"
Monty Python's Life of Brian
75
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Interfacing to C and void*
2006-02-20 15:19 Interfacing to C and void* Maciej Sobczak
2006-02-20 18:24 ` Georg Bauhaus
@ 2006-02-20 19:01 ` Martin Krischik
2006-02-20 19:41 ` Martin Dowie
1 sibling, 1 reply; 7+ messages in thread
From: Martin Krischik @ 2006-02-20 19:01 UTC (permalink / raw)
Maciej Sobczak wrote:
> Hi,
>
> Suppose I have the following two C functions:
>
> void * factory();
> void sink(void *p);
>
> I use them this way:
>
> void *someObject = factor();
> sink(someObject);
>
>
> What is the recommended approach to interfacing to such functions from
> Ada? I cannot find anything (in part B of AARM) that would help with
> void*. Of course, I could wrap these functions into something that uses
> long values (or some other tokens) and appropriate mapping at the level
> of the wrapper, but I still hope there is more direct way.
http://en.wikibooks.org/wiki/Ada_Programming/Memory#Where_is_void.2A.3F
Martin
--
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-02-21 18:47 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-20 15:19 Interfacing to C and void* Maciej Sobczak
2006-02-20 18:24 ` Georg Bauhaus
2006-02-20 18:54 ` Jeffrey R. Carter
2006-02-20 19:01 ` Martin Krischik
2006-02-20 19:41 ` Martin Dowie
2006-02-21 8:09 ` Alex R. Mosteo
2006-02-21 18:47 ` Martin Krischik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox