[fpc-devel]SizeOf() reports 0 for Var Paramaters. (1.1)
Marco van de Voort
marcov at stack.nl
Sun Jul 27 23:34:30 CEST 2003
> O_o Woah.. Weird. Ok.. I thought it worked.. but mabey not. 1.0.6 seems
> to return 4 for SizeOf() a var param. While 1.1 returns 0.
It can't work, simply because it is impossible for the procedure
to get the size of such a parameter (incl the const variant).
The compiler can't know it when compiling (several routines could
call this routine with different sizes), and there is no runtime
info passed.
In general:
procedure dotest (var a); // const case is the same
-> only pointer to "a" is passed. No way to determine type, number
of elements or #bytes.
procedure dotest (var a: array of longint);
-> pointer + number of elements is passed.
procedure dotect (const a: array of const); // delphi construct
-> 1. a tabel with a pointer and a typecode for each item is
created on the stack
2. a pointer to that item+ number of items is pushed onto the stack
The last one needs to be called like
dotect([param1,param2,param3]);
More information about the fpc-devel
mailing list