TArray <Byte> VS TBytes VS PByteArray

These 3 types are very similar ...

TArray is a generic version of TBytes. Both can be sent to PByteArray and used as a buffer for calls to the Windows API. (with the same limitations as the string for Pchar).

What I would like to know: This is "by design" or "By implementation" behavior. Or, more specifically, could it happen in a future release?

// Edit As said below ... What I really want to know is: Is it safe for TBytes (or TArray) types for PByteArray, as well as String type for PChar, with regard to direct compatibility. (Or maybe AnsiString for PAnsiChar is the best example ^ _ ^)

+5
source share
2

, , , . , , Delphi .

EDIT: , , .

, C-. , .

0 C-. .

+3

( ). -, .

TArray ", TBytes. TByteArray (, PByteArray).

TByteArray, PByteArray, , , ( ). , . , 2 ^ 15 (0..32767). ( > 32767) PByteArray :

var
  b: Byte;
  ab: TArray<Byte>;
  pba: PByteArray;
begin
  SetLength(ab, 100000);
  pba := @ab;             // << No cast necessary - the compiler knows (magic!)
  b   := pba[62767];      // << COMPILE ERROR!
end;

. TArray PByteArray , > 32K ( , ). , , ( "" ).

, , , , , . - -.

+1

All Articles