[Lazarus] Got "Pointer", expected "Open Array Of Char"

Howard Page-Clark hdpc at talktalk.net
Sun Jan 13 15:11:25 CET 2013


On 13/1/13 1:58, Dave Coventry wrote:
> On 13 January 2013 14:56, leledumbo <leledumbo_cool at yahoo.co.id> wrote:
>> Or const since it's meant to be read only
>
> Hmmm.
>
> Doesn't help. Still getting the same error.
>
> I've tried passing the src parameter as a Pointer and then casting it
> as an array of Char.
>
> procedure Copybytes(var dst: Pointer; src: Pointer; len: integer);
> var
>    i: integer;
>    data_in,data_out: Array of Char;
> begin
>    data_in:=@src;
>    data_out:=@dst;
>    for i:=0 to len-1 do
>    begin
>      data_out[i]:=data_in[i];
>    end;
> end;
>
> Calling the procedure:     Copybytes(@dst[dloc], at src[sloc],16);
>
> I get the error
>
> Error: Can't assign values to an address

One source of confusion arises because your parameter declaration "array 
of char" in procedure Copybytes(var dst: array of Char ...
means something different from your variable declaration

var
  data_in, data_out: Array of Char;

where "Array of Char" denotes a dynamic array - rather different from 
the parameter-passing declaration.





More information about the Lazarus mailing list