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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d71460587da14d5b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-31 10:13:03 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: mheaney@on2.com (Matthew Heaney) Newsgroups: comp.lang.ada Subject: Re: Importing C structs? Date: 31 Jul 2003 10:13:02 -0700 Organization: http://groups.google.com/ Message-ID: <1ec946d1.0307310913.aadf9fc@posting.google.com> References: <1V1Wa.299$jp.55@newsread4.news.pas.earthlink.net> NNTP-Posting-Host: 66.162.65.162 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1059671583 30291 127.0.0.1 (31 Jul 2003 17:13:03 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 31 Jul 2003 17:13:03 GMT Xref: archiver1.google.com comp.lang.ada:41089 Date: 2003-07-31T17:13:03+00:00 List-Id: Ching Bon Lam wrote in message news:... > "Matthew Heaney" wrote in > news:1V1Wa.299$jp.55@newsread4.news.pas.earthlink.net: > > > The type of parameter file is incorrect. The char_array type is an > > unconstrained Ada array type, which does not correspond directly to > > any C type. Specifically, your problem is that on the Ada side a dope > > vector describing the array object is passed -- this is definitely > > *not* what you want. > > > > You need to use the type Interfaces.C.Strings.chars_ptr instead. > > const char * is in this context the same as a string, which is in fact an > array of char. and interfaces.c.char_array is the same thing. and with > chars_ptr you need to make an extra temp variable for the conversion. It depends on how an object whose type is an unconstrained array is passed to an operation that has C convention. The Ada convention is to pass a dope vector which describes the string (its index bounds and length). I just read RM95 B.3 (70), which states that the array really is passed as a T*, so it looks like you may be OK. However, note that B.3 (73) states that it is the programmer's responsibility to ensure that the array is null terminated, so make sure you don't forget...