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,dbe05983bbe093ca X-Google-Attributes: gid103376,public From: Tucker Taft Subject: Re: Interfaces.C.Strings_Chars_Ptr as an out mode parameter Date: 1999/06/11 Message-ID: <37611FB6.BBFF0F09@averstar.com>#1/1 X-Deja-AN: 488428215 Content-Transfer-Encoding: 7bit Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.burl.averstar.com References: <7jpe2e$m7i@hobbes.crc.com> Content-Type: text/plain; charset=us-ascii Organization: AverStar (formerly Intermetrics) Burlington, MA USA Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-06-11T00:00:00+00:00 List-Id: David C. Hoos, Sr. wrote: > ... > So... the question is.. if one wishes to have a > procedure with a profile of, say: > > procedure My_Proc (Result : out Interfaces.C.Strings.Chars_Ptr); > > is it legal to export it like so: > > pragma Export (C, My_Proc, "My_Proc"); > > where the C prototype is void My_Proc (char * result); The C prototype should be: void My_Proc (char ** result); because "out" parameters are given an extra level of indirection. The caller must also use "&" on the actual parameter (in C). > The results I'm having are that if the exported procedure > is called from Ada, everything works as expected. > > If called from C, a Segmentation fault occurs at the > point where the out mode parameter is assigned its > value in the Ada procedure My_Proc. Doesn't surprise me. > What say ye? -- -Tucker Taft stt@averstar.com http://www.averstar.com/~stt/ Technical Director, Distributed IT Solutions (www.averstar.com/tools) AverStar (formerly Intermetrics, Inc.) Burlington, MA USA