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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,fb17569fccf2604b X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!j19g2000yqk.googlegroups.com!not-for-mail From: Vadim Godunko Newsgroups: comp.lang.ada Subject: Re: Trouble writing Ada callback from C Date: Sat, 12 Sep 2009 11:40:27 -0700 (PDT) Organization: http://groups.google.com Message-ID: <241a6745-0848-4bd0-bb1b-1e826e084911@j19g2000yqk.googlegroups.com> References: NNTP-Posting-Host: 93.178.77.161 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1252780827 9850 127.0.0.1 (12 Sep 2009 18:40:27 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 12 Sep 2009 18:40:27 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: j19g2000yqk.googlegroups.com; posting-host=93.178.77.161; posting-account=niG3UgoAAAD7iQ3takWjEn_gw6D9X3ww User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.13) Gecko/2009080200 SUSE/3.0.13-0.1.2 Firefox/3.0.13,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:8307 Date: 2009-09-12T11:40:27-07:00 List-Id: On Sep 11, 11:57=A0am, Jerry wrote: > I have a problem with writing an Ada procedure, used as a callback > from C, in which one of the arguments is an output char * (in the C > version). The actual length of the returned "string" isn't known at > calling time, even though the caller apparently allocates 40 > characters (see below). However, the actual number of characters > returned by the C version is less than 40. > > My problem is how to pass probably a char_array back out which is the > correct length, but which length is not known at the time the Ada > callback is called from C. > subtype constrained_char_array is Interfaces.C.char_array (1 .. 40); procedure Y (X : out constrained_char_array); pragma Convention (C, Y);