[fpc-pascal] Blockread and buffers

Peter J. Haas fpc.ml at pjh2.de
Tue Mar 22 18:13:52 CET 2005

Hi Peter,

on 2005-03-22T08:36:36+01:00 Peter wrote:

>> Hmmm... Just pure curiosity:
>> I am getting a warning "Variable does not seem to be initialized" on a
>> code
>> from FreePascal RTL guide:
>>     BlockRead (Fin,buf,Sizeof(buf),NumRead); // <-- Warning here (buf)

> There are no warning/notes when compiled with 1.9.8.

This is true, but there should be a warning. With other words, there
are two bugs (or missing features).

BlockRead is declared as

Procedure BlockRead(var f:File;var Buf;count:Word;var Result:Word);[IOCheck];

var do mean, Result is a in/out parameter, it should be initialized
before the call. Actually Result is a out-only parameter, therefore
the declaration should be:

procedure BlockRead(var f: File; out Buf; Count: Word; out Result: Word); [IOCheck];

BTW: I don't have found [IOCheck] in the documentation, maybe it
should be described for programmers, which want to write file handling
functions which use the IOResult aka InOutRes error mechanism.

wkr Peter.

More information about the fpc-pascal mailing list