Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2016-02

How to pass an array of bytes directly in a TBytes param?

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

silvioprog

Hello,

Consider the following procedure:

procedure test(b: TBytes);
begin
end;

The common way to pass an array of bytes in this procedure is declaring and initializing a TBytes variable. But in Delphi (XE) I just do:

  test([65, 66, 67]);

However, when I try it on FPC (trunk), I get:

"Error: Incompatible type for arg no. 1: Got "{Array Of Const/Constant Open} Array of ShortInt", expected "TBytes"".

Is this feature supported in FPC? If so, how to use that?!

Thank you!

Silvio Clécio

Reply by email

Dmitry Boyarintsev
to silvioprog
procedure test(const b: array of byte) ??
silvioprog wrote 25 lines
Hello, Consider the following procedure: procedure test(b: TBytes); begin end; The common way to pass an array of bytes in this procedure is declaring and initializing a TBytes variable. But in Delphi (XE) I just do: test([65, 66, 67]); However, when I try it on FPC (trunk), I get: "Error: Incompatible type for arg no. 1: Got "{Array Of Const/Constant Open} Array of ShortInt", expected "TBytes"". Is this feature supported in FPC? If so, how to use that?! Thank you! -- Silvio Clécio

Reply by email

silvioprog
to Dmitry Boyarintsev

On Fri, Feb 19, 2016 at 10:37 PM, Dmitry Boyarintsev <

wrote: procedure test(const b: array of byte) ??

I know it using an array of bytes, but does it compiles if the parameter is declared as TBytes? I don't know if FPC sopports it, so I'm askig just to check if it is possible (enabling some switch).

Silvio Clécio

Reply by email