[fpc-pascal] Dynamic array as result of class method?

Jonas Maebe jonas.maebe at elis.ugent.be
Sun Nov 7 11:23:03 CET 2010


On 07 Nov 2010, at 11:05, Bo Berglund wrote:

>    function Read(Count: Cardinal): array of byte; overload;
>  end;
> 
> But when I use the Ctrl-Shift-C command on this to make Lazarus
> complete the code I get an error on the second Read line:
> sscomm.pas(40,37) Error: identifier expected, but array found
> 
> Is it illegal to specify a dynamic array as the result type of a
> function?

No, but you cannot declare it inline, just like you cannot have

function read(count: cardinal): record b: byte end;

Use a separately defined type:

type
  tbytearray = array of byte;


Jonas



More information about the fpc-pascal mailing list