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,ef6c792702c0ff46,start X-Google-Attributes: gid103376,public From: Al Johnston Subject: ada to c interfaces and CHARS_PTR Date: 2000/03/09 Message-ID: <38C7E515.29C42580@mindspring.com>#1/1 X-Deja-AN: 595248963 Content-Transfer-Encoding: 7bit Organization: MindSpring Enterprises X-Accept-Language: en X-Server-Date: 9 Mar 2000 17:55:27 GMT Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-03-09T17:55:27+00:00 List-Id: I have been trying (for longer than I care to admit) to use the following c subroutine from ada: --- begin c_sub.c --- #include #include #include void sub(const char *in_strg_fml,char **inout_strg_fml) { char t_buffer[25]; printf(" in c sub\n"); sprintf((char *)&t_buffer," you said => %s <==\0",in_strg_fml); *inout_strg_fml = strdup(t_buffer); printf(" %s\n",*inout_strg_fml); printf(" out c sub\n"); } ---- end c_sub.c ---- I wish to use the type CHARS_PTR from the ada.c.interface.strings package. Using this type to interface with c is the whole point of this exercise. Below is the section of ada code that attempts to use the above routine. The program cores when the c routine returns. I have not been able to find any examples using the CHARS_PTR type to interface with c (RM, Rat, GNAT adainc src). ---- begin a_sub.adb ---- with text_io; with interfaces.c.strings; use interfaces.c.strings; package body a_sub is procedure a_sub is procedure c_sub(in_strg_fml : CHARS_PTR; inout_strg_fml : in out CHARS_PTR); 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); 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; ---- end a_sub.adb ---- Some one please explan how this is done (using CHARS_PTR). thanks. -al