From: Jeffrey Carter <spam@spam.com>
Subject: Re: C bindings, Interfaces.C.Pointers etc.
Date: Tue, 11 May 2004 18:48:57 GMT
Date: 2004-05-11T18:48:57+00:00 [thread overview]
Message-ID: <te9oc.16468$Hs1.1407@newsread2.news.pas.earthlink.net> (raw)
In-Reply-To: <pan.2004.05.11.13.14.28.345191@linuxchip.demon.co.uk.uk.uk>
Dr. Adrian Wrigley wrote:
> Hi folks!
>
> I have a problem creating a binding to a C library.
>
> The library makes extensive use of arrays of arrays of structs.
> Both levels of arrays are of variable length.
>
> struct node { int index; double value; };
> struct problem { node **x; };
>
> When I attempt to define Ada types for this type of thing,
> I find I can't use access types to the arrays with the
> necessary C convention.
> "warning: this access type does not correspond to C pointer"
> is the compiler error.
-- struct node { int index; double value; };
type Node_Info is record
Index : Interfaces.C.Int;
Value : Interfaces.C.Double;
end record;
pragma Convention (C, Node_Info);
-- struct problem { node **x; };
type Node_Ptr is access all Node_Info;
pragma Convention (C, Node_Ptr);
type Node_Ptr_Ptr is access all Node_Ptr;
pragma Convention (C, Node_Ptr_Ptr);
type Problem_Info is record
X : Node_Ptr_Ptr;
end record;
pragma Convention (C, Problem_Info);
This compiles fine. This is an exact duplicate of the C declarations. To
deal with this using a higher level Ada abstraction, you'd wrap
something around this to provide that abstraction.
--
Jeff Carter
"Blessed is just about anyone with a vested interest in the status quo."
Monty Python's Life of Brian
73
next prev parent reply other threads:[~2004-05-11 18:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-11 13:14 C bindings, Interfaces.C.Pointers etc Dr. Adrian Wrigley
2004-05-11 18:17 ` tmoran
2004-05-11 18:48 ` Jeffrey Carter [this message]
2004-05-12 4:50 ` Simon Wright
2004-05-13 15:26 ` Dr. Adrian Wrigley
2004-05-12 6:30 ` Martin Krischik
2004-05-13 15:56 ` Dr. Adrian Wrigley
2004-05-13 17:37 ` Martin Krischik
2004-05-13 22:42 ` Jeffrey Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox