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, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,fce935e9f3aa1da8 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII From: "Egil H. H�vik" Newsgroups: comp.lang.ada References: <2ph6fjFkpsahU1@uni-berlin.de> <41342a34@193.71.169.73> Subject: Re: Interfacing with C: access/out parameters Date: Tue, 31 Aug 2004 11:11:01 +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: <41343c0e@193.71.169.73> X-Trace: 31 Aug 2004 10:51:26 +0200, 193.71.174.141 Path: g2news1.google.com!news2.google.com!proxad.net!newsfeed.stueberl.de!feed.news.tiscali.de!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:3199 Date: 2004-08-31T11:11:01+02:00 List-Id: "Egil H. H�vik" wrote in message news:41342a34@193.71.169.73... > > "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 hmm... Copy-Paste error here... Should be Blah(Datum), minus Thin_Package > 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 > >