[fpc-pascal]sizeof returns wrong size?

Ivan Montes senbei at terra.es
Wed Mar 27 01:44:51 CET 2002

>> 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. 

if you finish the array with a null value you can know when is finish and so the length of it.
but as jonas said it'll be better to pass an argument to the function with the length of the buffer:
Procedure Win32Write (Col,Row : byte; "length :dword;" var SourceData);


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20020327/7f48385b/attachment.html>

More information about the fpc-pascal mailing list