Recent

Author Topic: warn 5024  (Read 1817 times)

Чебурашка

  • Hero Member
  • *****
  • Posts: 586
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
warn 5024
« on: August 23, 2023, 11:57:20 am »
Hello,
I work under lazarus-linux (see below the version). For some reason I have a unit that generates several hints about unsed params (this is a tempoarary situation, eventually I will fix their usage).

When I use Lazarus to buid, I see in the messages window "Hide message by adding {$warn 5024 off} to <MyUnit.pas>".
If I click this menu item, the line is added at top.

Code: Pascal  [Select][+][-]
  1. unit MyUnit;
  2.  
  3. {$WARN 5024 off : Parameter "$1" not used}
  4.  
  5. interface
  6.  

but when rebuilding I still see all the messages that were supposed to be hidden.


Is that about my Lazarus version or am I doing smtg wrong?
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

qk

  • New Member
  • *
  • Posts: 33
Re: warn 5024
« Reply #1 on: August 23, 2023, 02:01:35 pm »
Have you tried with simple line below?
Code: Pascal  [Select][+][-]
  1. {$WARN 05024 OFF}

Thaddy

  • Hero Member
  • *****
  • Posts: 16387
  • Censorship about opinions does not belong here.
Re: warn 5024
« Reply #2 on: August 24, 2023, 09:09:59 am »
Have you tried with simple line below?
Code: Pascal  [Select][+][-]
  1. {$WARN 05024 OFF}
That is wrong, since it is not 05024, but 5024. (Yes that means a different thing!)
It is also wrong because with {$WARN number ON/OFF everything after ON/OFF up until the closing bracket is interpreted as a comment and perfectly legal.

In principle the original line is therefor correct and that unit should not return parameter not used warnings, unless there is an overriding command line option used.
We need to know the build settings if that unit still throws that warning, but note that the uses clause from that unit can also pull in other units that may reset the value ON/OFF...
I would rather see the whole unit if it is possible.
Another note is that you can use {$PUSH}/{$POP} around the offending declarations:
Code: Pascal  [Select][+][-]
  1. {$push}{$warn 5024 off}
  2. procedure test(par:integer);
  3. begin
  4. //
  5. end;
  6. {$POP}
which can help to remove the warning only when it is really needed.
« Last Edit: August 24, 2023, 09:20:05 am by Thaddy »
There is nothing wrong with being blunt. At a minimum it is also honest.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5815
  • Compiler Developer
Re: warn 5024
« Reply #3 on: August 24, 2023, 09:59:39 pm »
Have you tried with simple line below?
Code: Pascal  [Select][+][-]
  1. {$WARN 05024 OFF}
That is wrong, since it is not 05024, but 5024. (Yes that means a different thing!)

They are the same. Pascal uses & for octal numbers, not 0.

but when rebuilding I still see all the messages that were supposed to be hidden.

Do you have a more complete example than just a snippet?

Thaddy

  • Hero Member
  • *****
  • Posts: 16387
  • Censorship about opinions does not belong here.
Re: warn 5024
« Reply #4 on: August 25, 2023, 04:59:09 pm »
In this case I am right, because the compiler, well the parser threats as string, so 05024 <> 5024 by definition.
There is nothing wrong with being blunt. At a minimum it is also honest.

bytebites

  • Hero Member
  • *****
  • Posts: 694
Re: warn 5024
« Reply #5 on: August 26, 2023, 07:07:35 am »
Result is same with 5024 and 05024.

Thaddy

  • Hero Member
  • *****
  • Posts: 16387
  • Censorship about opinions does not belong here.
Re: warn 5024
« Reply #6 on: August 26, 2023, 02:50:32 pm »
No it is not! the interpreter part evaluates as string, not as a numeric value... So they are very different. >:D
There is nothing wrong with being blunt. At a minimum it is also honest.

bytebites

  • Hero Member
  • *****
  • Posts: 694
Re: warn 5024
« Reply #7 on: August 26, 2023, 03:54:12 pm »
Try it yourself.
Code: Pascal  [Select][+][-]
  1. program Project1;
  2.  
  3. {$WARN 05024 OFF}
  4.  
  5. procedure foo(unused:boolean);
  6. begin
  7.   writeln('hello');
  8. end;
  9.  
  10. begin
  11.   foo(false);
  12. end.
  13.  

PascalDragon

  • Hero Member
  • *****
  • Posts: 5815
  • Compiler Developer
Re: warn 5024
« Reply #8 on: August 27, 2023, 12:00:00 pm »
In this case I am right, because the compiler, well the parser threats as string, so 05024 <> 5024 by definition.

You are wrong. Any digit in the range of '0'..'9' after a whitespace or non-identifier character will lead to the parsing of a number and not a string (see tscannerfile.readtoken in scanner.pas at around line 5249). A string constant can only be started by a '.

WooBean

  • Sr. Member
  • ****
  • Posts: 278
Re: warn 5024
« Reply #9 on: August 27, 2023, 07:16:30 pm »
A string constant can only be started by a '.

Not all in PascalDragon's post is true in context of the subject. Directive $WARN (FPC 3.2.2) has about 20 predefined identifiers (CONSTRUCTING_ABSTRACT, ... ,INTF_RAISE_VISIBILITY) which can be used to switch on/off compiler warnings. Using those identifiers as strings (e.g. {$WARN 'NO_RETVAL' OFF}) will not work.

Platforms: Win7/64, Linux Mint Ulyssa/64

PascalDragon

  • Hero Member
  • *****
  • Posts: 5815
  • Compiler Developer
Re: warn 5024
« Reply #10 on: August 29, 2023, 09:19:03 pm »
A string constant can only be started by a '.

Not all in PascalDragon's post is true in context of the subject. Directive $WARN (FPC 3.2.2) has about 20 predefined identifiers (CONSTRUCTING_ABSTRACT, ... ,INTF_RAISE_VISIBILITY) which can be used to switch on/off compiler warnings. Using those identifiers as strings (e.g. {$WARN 'NO_RETVAL' OFF}) will not work.

I never said that you can use string constants with {$warn}, I only said that string constants are started with ' (and that's what this was about: string constants). CONSTRUCTING_ABSTRACT and Co. are exactly what you mentioned: identifiers. That's a difference.

 

TinyPortal © 2005-2018