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 X-Google-Thread: 103376,ef6c792702c0ff46 X-Google-Attributes: gid103376,public From: gisle@spurv.ii.uib.no (Gisle S�lensminde) Subject: Re: ada to c interfaces and CHARS_PTR Date: 2000/03/09 Message-ID: #1/1 X-Deja-AN: 595297685 Content-Transfer-Encoding: 8bit References: <38C7E515.29C42580@mindspring.com> Organization: University of Bergen, Norway Content-Type: text/plain; charset=iso-8859-1 Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-03-09T00:00:00+00:00 List-Id: In article <38C7E515.29C42580@mindspring.com>, Al Johnston wrote: >I have been trying (for longer than I care to admit) to use the >following c subroutine from >ada: C has not 'in out' parameters, only 'in' parameters. To pass the pointer to the string you can use system'address. str'address is equivalent to &str in C. The following Ada code can replace the Ada code of your last posting: with text_io; with interfaces.c.strings; with System; use interfaces.c.strings; package body a_sub is procedure a_sub is procedure c_sub(in_strg_fml : CHARS_PTR; inout_strg_fml : System.address); pragma import(c,c_sub,"sub"); in_strg_act : CHARS_PTR; inout_strg_act : CHARS_PTR := Null_Ptr; begin text_io.put_line(" in a_sub"); in_strg_act := NEW_STRING("I am here"); c_sub(in_strg_act, Inout_Strg_Act'address); text_io.put_line("----------"); text_io.put_line("He said ==>> " & VALUE(inout_strg_act) & " <<=="); text_io.put_line(" out a_sub"); end a_sub; end a_sub; -- Gisle S�lensminde ( gisle@ii.uib.no ) ln -s /dev/null ~/.netscape/cookies