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=-0.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,fce935e9f3aa1da8 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Egil H. H�vik" Newsgroups: comp.lang.ada References: <2ph6fjFkpsahU1@uni-berlin.de> Subject: Re: Interfacing with C: access/out parameters Date: Tue, 31 Aug 2004 09:54:51 +0200 Organization: Kongsberg Defence & Aerospace X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 193.71.174.141 Message-ID: <41342a34@193.71.169.73> X-Trace: 31 Aug 2004 09:35:16 +0200, 193.71.174.141 Path: g2news1.google.com!news1.google.com!news.glorb.com!news.zanker.org!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!uio.no!193.75.75.20.MISMATCH!news.eunet.no!193.71.169.73!193.71.174.141 Xref: g2news1.google.com comp.lang.ada:3198 Date: 2004-08-31T09:54:51+02:00 List-Id: "Jano" wrote in message news:2ph6fjFkpsahU1@uni-berlin.de... > Hi, > > function Blah (Datum : access Data) return C.Int; > pragma Import (C, Blah); > > > Procedure Ada_Blah (Datum : out Data); > -- May raise some exception > > And my doubt, finally, is: can I ensure somehow that Datum is passed by > reference?, so I can do inside Ada_Blah [1]: > > Helper : aliased Datum; > For Helper'Address use Datum'Address; > if Thin_Package.Blah (Helper'Access) = Error_Value then > raise My_Error; > end if; > Well, you say Data is a record type, so what's wrong with: procedure Ada_Blah( Datum : out Data ) is function Blah( Datum : Data ) return C.int; pragma Import( C, Blah ); begin if Thin_Package.Blah(Datum) = Error_Value then raise My_Error; end if; end Ada_Blah; B.3(65): "An Ada function corresponds to a non-void C function" B.3(69): "An Ada parameter of a record type T, of any mode, is passed as a t* argument to a C function, where t is the C type corresponding to the Ada type T." ~egilhh