From: "Matthew Heaney" <matthew_heaney@acm.org>
Subject: Re: Question about interfacing C and Ada95
Date: 1999/11/09
Date: 1999-11-09T00:00:00+00:00 [thread overview]
Message-ID: <3828affe_3@news1.prserv.net> (raw)
In-Reply-To: 808la7$4b9$1@trog.dera.gov.uk
The following Ada code works correctly with the C code you posted in
your last message.
If you prefer to use functions (instead of procedures), in order to
return the Error_Code as the return value of the function, it's simple
enough to do that.
--STX
with Text_IO; use Text_IO;
with Interfaces.C; use Interfaces;
with System;
procedure get is
type Access_Int_Type is access all C.Int;
pragma Convention (C, Access_Int_Type);
type Access_C_Float_Type is access all C.C_Float;
pragma Convention (C, Access_C_Float_Type);
type Instance_Type is access all System.Address;
pragma Convention (C, Instance_Type);
Error_Code : aliased C.Int;
Instance : aliased System.Address;
Val : aliased C.C_Float;
procedure Create_Object
(Instance : in Instance_Type;
Error_Code : in Access_Int_Type);
pragma Import (C, Create_Object, "createObject");
procedure Get_Float
(Instance : in Instance_Type;
Val : in Access_C_Float_Type;
Error_Code : in Access_Int_Type);
pragma Import (C, Get_Float, "getFloat");
begin -- get
Create_Object (Instance'Access, Error_Code'Access);
Put_Line (C.Int'Image (Error_Code));
Get_Float (Instance'Access, Val'Access, Error_Code'Access);
Put_Line (C.Int'Image (Error_Code));
Put_Line (C.C_Float'Image (Val));
end get;
next prev parent reply other threads:[~1999-11-09 0:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-11-08 0:00 Question about interfacing C and Ada95 Hovers
1999-11-08 0:00 ` Robert Dewar
1999-11-09 0:00 ` Hovers
1999-11-09 0:00 ` Ted Dennison
1999-11-12 0:00 ` Hovers
1999-11-12 0:00 ` Robert Dewar
1999-11-12 0:00 ` Ted Dennison
1999-11-13 0:00 ` Robert Dewar
1999-11-09 0:00 ` Matthew Heaney [this message]
1999-11-08 0:00 ` Matthew Heaney
1999-11-08 0:00 ` tmoran
1999-11-09 0:00 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox