Re: Interfacing with C - pointer problem



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);
.



Relevant Pages

  • Re: Optimization of code
    ... When I compile the code you gave me to search for string I get 3 errors, ... LPSTR found = strstr; ... I beg to differ that you didn't use CStringA ...
    (microsoft.public.vc.mfc)
  • LPSTR an Funktion übergeben
    ... ] String szText); ... Stringchar test = new Stringchar; ... Also gehe ich davon aus das ich irgendwas mit dem LPSTR ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • RE: Question about different string type in VC++
    ... Since you have probably modified the string, ... I want to write a simple Trim() function to trim the spaces around a ... > LPSTR string. ... > CString sInput; ...
    (microsoft.public.vc.mfc)
  • Re: Need help calling a proprietary C DLL from Python
    ... LPBSTR = POINTER ... VmxInfo.argtypes = [LPHANDLE, LPSTR] ... res = VmxInfo, byref) ... Note how the string buffer parameter has NO odd games on it. ...
    (comp.lang.python)
  • Re: But..... WHY??? Access Violation
    ... Since the function later on pokes nulls into the string it's ... LPCSTR and LPSTR are stupid names for types anyhow. ...
    (comp.lang.cpp)