Re: What is the best way to define the Imported C function



On Sat, 26 Jan 2008, Dmitry A. Kazakov wrote:

Surely, you would like to make a wrapper around the mess to make it more
Ada-friendly:

Such a wrapper looks like a typical "please inline me" function:

type Display_ID is private; -- An opaque handle to
type Screen_ID is private;
-- This either does the job or raises an exception
procedure Parse_Display ( [...] );
pragma inline (Parse_Display); -- *** this seems to make sense ***

private
...
procedure Parse_Display ( [...] ) is
function Internal ( [...] ) return Interfaces.C.int;
pragma Import (C, Internal, "xcb_parse_display");
[...]
Result : Interfaces.C.int := Internal ( [...] );
begin
if Result = 0 then
[...]
else
raise [...];
end if;
end Parse_Display;


--
Stefan Lucks (moved to Bauhaus-University Weimar, Germany)
<Stefan.Lucks at medien.uni-weimar.de>
------ I love the taste of Cryptanalysis in the morning! ------


.



Relevant Pages