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