[fpc-pascal] How to eliminate specific hint (was: how to initialize a SearchRec var?)

Sven Barth pascaldragon at googlemail.com
Fri Jan 3 12:07:27 CET 2014


Am 03.01.2014 11:06 schrieb "Pierre Free Pascal" <pierre at freepascal.org>:
>
> > // 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 ===
>
>   The is a more specific way to remove a given hint:
>
> Use -vq option to get the numeric value of the message:
>
> E:\pas\test>ppc386 -vhq tsearchrec.pas
> Hint: (11030) Start of reading config file
> e:\pas\fpc-2.7.1\bin\i386-win32\fpc.cfg
> Hint: (11031) End of reading config file
> e:\pas\fpc-2.7.1\bin\i386-win32\fpc.cfg
> tsearchrec.pas(13,20) Hint: (5058) Variable "dirinfo" does not seem to be
> initialized
>
> Disable that specific message by using -vm option:
>
> E:\pas\test>ppc386 -vh -vm5058 tsearchrec.pas
> Hint: Start of reading config file e:\pas\fpc-2.7.1\bin\i386-win32\fpc.cfg
> Hint: End of reading config file e:\pas\fpc-2.7.1\bin\i386-win32\fpc.cfg
>
> Magic, isn't it?

Maybe one should also mention that this can be done in code as well for
specific locations:

=== code begin ===
{$push}
{$warn 5058 off}
// whatever
{$pop}
=== code end ===

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140103/016dee6c/attachment.html>


More information about the fpc-pascal mailing list