[fpc-pascal]sizeof returns wrong size?
jonas at zeus.rug.ac.be
Tue Mar 26 22:51:22 CET 2002
On Tue, 26 Mar 2002 James_Wilson at i2.com wrote:
> I'm attempting to write a generic writeln type of procedure for win32
> console mode programs, but I'm having trouble using sizeof. I'm reasonably
> certain I've got it written correctly, but perhaps I'm missing something.
The thing you're missing is that sizeof() is always evaluated at
comnpile-time, never at run-time.
> Procedure Win32Write (Col,Row : byte; var SourceData);
> BuffSize : TCoord;
> BuffCoord : TCoord;
> DestRect : TSmallRect;
> // BuffSize is how big a window to write
> BuffSize.X := sizeof (SourceData);
This will always return 4 I think (because a generic "var" parameter is
simply a pointer to whatever data you are passing to the routine).
You will have to add an explicit size parameter to your routine to solve
More information about the fpc-pascal