comp.lang.ada
 help / color / mirror / Atom feed
From: mheaney@on2.com (Matthew Heaney)
Subject: Re: Importing C structs?
Date: 31 Jul 2003 10:13:02 -0700
Date: 2003-07-31T17:13:03+00:00	[thread overview]
Message-ID: <1ec946d1.0307310913.aadf9fc@posting.google.com> (raw)
In-Reply-To: Xns93C98A38494B8cblamstudentutwenten@194.109.133.20

Ching Bon Lam <c.lam_REMOVE_THIS@student.utwente.nl> wrote in message news:<Xns93C98A38494B8cblamstudentutwenten@194.109.133.20>...
> "Matthew Heaney" <matthewjheaney@earthlink.net> 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...



  parent reply	other threads:[~2003-07-31 17:13 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-30 20:03 Importing C structs? Freejack
2003-07-30 20:52 ` chris
2003-07-30 21:26   ` Freejack
2003-07-30 23:50   ` tmoran
2003-07-31 10:53     ` chris
2003-08-04 14:33     ` Andreas Almroth
2003-08-04 15:16       ` Samuel Tardieu
2003-08-04 20:07         ` Randy Brukardt
2003-07-31 17:14   ` Warren W. Gay VE3WWG
2003-08-12  0:02     ` chris
2003-07-31 18:17   ` Xenos
2003-07-31 19:16     ` Simon Wright
2003-07-31 20:17       ` Samuel Tardieu
2003-07-31 20:40       ` Xenos
2003-07-30 23:14 ` Ching Bon Lam
2003-07-31  0:07   ` tmoran
2003-07-31  5:35   ` Matthew Heaney
2003-07-31  7:46     ` Freejack
2003-07-31  9:27       ` Martin Dowie
2003-07-31 21:41         ` Freejack
2003-08-01  7:39           ` Martin Dowie
2003-07-31 17:34       ` Matthew Heaney
2003-07-31 11:29     ` Ching Bon Lam
2003-07-31 16:59       ` Matthew Heaney
2003-07-31 17:32         ` Warren W. Gay VE3WWG
2003-07-31 17:13       ` Matthew Heaney [this message]
2003-07-31 17:40       ` Randy Brukardt
2003-07-31  5:21 ` Matthew Heaney
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox