FPC $HINTS OFF/ON, $WARNINGS OFF/ON are global scoped but the document says it is unit scope based (just like Delphi)
Original Reporter info from Mantis: jakubklos
-
Reporter name: Jakub Klos - IceWarp
Original Reporter info from Mantis: jakubklos
- Reporter name: Jakub Klos - IceWarp
Description:
If you use a block like below in a unit it affects the parent unit which uses this unit. This means that the parent unit has a problem because local $HINTS OFF/ON are controlled also by child used units. The documentation says it should be unit scope based (just like in Delphi) but it is global.
$HINTS OFF
...
$HINTS ON
Steps to reproduce:
I have a made a reproduction code with comments. If you build (you need to clean build always) the code then you get a HINT but you should not because the main program has a $HINTS OFF usage.
Reproduction code follows (in the zip as well).
test.pp:
program test;
// This should suppress the x: unused variable hint - but it will not because there is $NOTES ON in testunit.pas. It should be unit scope based though.
{$NOTES OFF}
// If you comment the testunit the x: unusued variable hint will be suppressed properly
uses testunit;
var
x: byte;
begin
writeln('test');
end.
testunit.pp:
unit testunit;
interface
implementation
{$NOTES OFF}
// Something will be done here - not important what
// ...
// Enable notes b (should be unit scope - but it is not - seems to be global)
{$NOTES ON}
// Used to suppress "not used unit testunit.pp in the parent test.pp"
uses
sysutils;
initialization
sleep(0);
end.
Additional information:
There is a workaround to this problem. If you use the {PUSH} {
POP} it will work but IMHO FPC compiler should do this automatically when compiling a new unit.
Mantis conversion info:
- Mantis ID: 35063
- Version: 3.0.4
- Fixed in version: 3.3.1