<p>Am 03.01.2014 10:34 schrieb "Graeme Geldenhuys" <<a href="mailto:graeme@geldenhuys.co.uk">graeme@geldenhuys.co.uk</a>>:<br>
><br>
> On 2014-01-02 19:21, waldo kitty wrote:<br>
> ><br>
> > we do not want to turn off hints so how can we initialize dirinfo and make fpc<br>
> > happy?<br>
><br>
><br>
> I hate such hints too! This is what I did in my code to prevent that<br>
> unwanted hint.<br>
><br>
> One part is the usage of an out parameter, and the second part is the<br>
> {$HINT OFF} directive.<br>
><br>
><br>
> ----8<-------------8<-------------8<-------------8<-------------8<----<br>
> program test_SearchRec;<br>
><br>
> uses<br>
> Dos;<br>
><br>
> const<br>
> pattern : string = '*.pas';<br>
><br>
> var<br>
> dirinfo : SearchRec;<br>
><br>
> // prevents the compiler hint about not initialized variables<br>
> procedure dcpFillChar(out x; count: SizeInt; Value: Byte);<br>
> begin<br>
> {$HINTS OFF}<br>
> FillChar(x, count, value);<br>
> {$HINTS ON}<br>
> end;<br>
><br>
><br>
> begin<br>
><br>
> dcpFillchar(dirinfo,sizeof(dirinfo),$00);<br>
> FindFirst(pattern,AnyFile,dirinfo);<br>
> findclose(dirinfo);<br>
> end.<br>
> ----8<-------------8<-------------8<-------------8<-------------8<----</p>
<p>I would suggest to use the following sequence instead:</p>
<p>=== code begin ===</p>
<p>{$push}<br>
{$hints off}<br>
// whatever<br>
{$pop}</p>
<p>=== code end ===</p>
<p>This way if the hints are switched off before that code is reached they will stay off afterwards instead of being switched on.</p>
<p>Regards,<br>
Sven</p>