Sign in Join

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

Mailing lists / fpc-pascal / 2002-12

How to know the size of a untype var parameter

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Judison

Hi all,

There is a way to know the size of a untype var param?

Something like this:

procedure MyProc(var A);
begin
  WriteLn('SizeOf(A) = ', SizeOf(A));
end;

but it always returns 4, as Data is a actually a pointer, SizeOf(A^) does not compile, SizeOf(Pointer(A)^), Pointer(A) is typecasting the data pointed by A...

TIA
Judison

Florian Klaempfl
to Judison
Judison wrote 13 lines
Hi all, There is a way to know the size of a untype var param? Something like this: procedure MyProc(var A); begin WriteLn('SizeOf(A) = ', SizeOf(A)); end; but it always returns 4, as Data is a actually a pointer, SizeOf(A^) does not compile, SizeOf(Pointer(A)^), Pointer(A) is typecasting the data pointed by A...

You've to pass the size in an extra parameter.