From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,782d14fd472db944 X-Google-Attributes: gid103376,public From: "Matthew Heaney" Subject: Re: Question about interfacing C and Ada95 Date: 1999/11/09 Message-ID: <3828affe_3@news1.prserv.net>#1/1 X-Deja-AN: 546659841 Content-transfer-encoding: 7bit References: <806ud0$lu1$1@trog.dera.gov.uk> <8076h5$d3c$1@nnrp1.deja.com> <808la7$4b9$1@trog.dera.gov.uk> Content-Type: text/plain; charset="US-ASCII" X-Complaints-To: abuse@prserv.net X-Trace: 9 Nov 1999 23:36:30 GMT, 32.101.8.79 Organization: Global Network Services - Remote Access Mail & News Services Mime-version: 1.0 Newsgroups: comp.lang.ada Date: 1999-11-09T00:00:00+00:00 List-Id: 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;