comp.lang.ada
 help / color / mirror / Atom feed
* Interfacing with C - pointer problem
@ 2007-01-30 14:23 Gerd
  2007-01-30 15:53 ` Frank J. Lhota
  2007-01-30 21:10 ` tmoran
  0 siblings, 2 replies; 5+ messages in thread
From: Gerd @ 2007-01-30 14:23 UTC (permalink / raw)


I try to call some C code, so I wrote me a simple interface, but it 
does not what I expected.

It looks like this:

  type LPSTR is access all String;

  procedure C_Func (x : LPSTR);  -- expects an address (C-pointer, 32-
bit)
  pragma Import (STDCALL, C_Func, "C_Func");

  procedure Q is
   data : aliased String := "ABC" & Ascii.Nul;

  begin
   C_Func (data'unchecked_access);
  end Q;

This does not work correct. What I found is, that data'Address is 32 
bit and LPSTR is 64 bit.

How to manage this?

I tried a "pragma Convention (C, LPSTR);" but this gives a warning. So 
what would be the right way?

Thanks in advance,
Gerd




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-01-31 23:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2007-01-31 18:10   ` Adam Beneschan
2007-01-31 23:53     ` Jeffrey R. Carter

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