[fpc-pascal]sizeof returns wrong size?

Andreas K. Foerster Andreas at AKFoerster.de
Wed Mar 27 06:56:06 CET 2002


On Tue, Mar 26, 2002 at 05:38:49PM -0500, James_Wilson at i2.com wrote:
> > 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 this.
> 
> Unfortunately, that won't work, primarily because the passed var could be 
> of any size. I'm hoping there's some way to get the actual size of the var 
> itself.

Before you call the procedure, it should be possible to use "sizeof".
It's just impossible, because it's untyped IN the procedure.

Try calling it like this:
Win32Write (Col, Row, SourceData, sizeof(SourceData));

-- 
Tschuess
	Andreas




More information about the fpc-pascal mailing list