[fpc-devel] Omit hint/warning for a fixed-size array

Ondrej Pokorny lazarus at kluug.net
Fri Aug 31 12:36:22 CEST 2018


On 31.08.2018 11:24, Michael Van Canneyt wrote:
> On Thu, 30 Aug 2018, Ondrej Pokorny wrote:
>> Hello,
>>
>> is there a way not to get a "Variable xyz does not seem to be 
>> initialized" hint/warning for a fixed-size array?
>>
>> program Project1;
>> uses Classes;
>> var
>>   Buffer: array[0..255] of Byte;
>>   FS: TFileStream;
>> begin
>>   // FillByte(Buffer, Length(Buffer), 0); // project1.lpr(9,18) Hint: 
>> Variable "Buffer" does not seem to be initialized
>>   FS := TFileStream.Create('test.test', fmOpenRead);
>>   FS.Read(Buffer[0], Length(Buffer)); // << project1.lpr(11,11) Hint: 
>> Variable "Buffer" does not seem to be initialized
>> end.
>>
>> What is the correct code that doesn't emit any hint or warning?
>
> Type
>   TByteBuffer = array[0..255] of Byte;
>
> Var
>   Buffer : TByteBuffer;
>
> begin
>   Buffer:=Default(TByteBuffer);
> end.

That was easy. Thank you!

Ondrej



More information about the fpc-devel mailing list