comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: Interfacing with C - pointer problem
Date: Tue, 30 Jan 2007 15:10:53 -0600
Date: 2007-01-30T15:10:53-06:00	[thread overview]
Message-ID: <aP-dnTYI5YPAKSLYnZ2dnUVZ_oWdnZ2d@comcast.com> (raw)
In-Reply-To: 1170167017.790966.225850@v45g2000cwv.googlegroups.com

>   type LPSTR is access all String;
>
> This does not work correct. What I found is, that data'Address is 32
> bit and LPSTR is 64 bit.
   Because LPSTR points to a dynamic size string and thus needs to
carry along bounds information.  A C LPSTR does not point to a dynamic
string, but instead points to a single character - the first in the
string.  So the match is
   type LPSTR is access Interfaces.C.Char;
   procedure C_Func (x : LPSTR);  -- expects an address (C-pointer, 32-bit)
and then
   data : Interfaces.C.char_array := Interfaces.C.To_C("ABC");
and
   C_Func (data(data'first)'unchecked_access);



  parent reply	other threads:[~2007-01-30 21:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-30 14:23 Interfacing with C - pointer problem Gerd
2007-01-30 15:53 ` Frank J. Lhota
2007-01-30 21:10 ` tmoran [this message]
2007-01-31 18:10   ` Adam Beneschan
2007-01-31 23:53     ` Jeffrey R. Carter
replies disabled

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