Recent

Author Topic: Suppressing warnings  (Read 2940 times)

srvaldez

  • Full Member
  • ***
  • Posts: 117
Re: Suppressing warnings
« Reply #15 on: February 23, 2024, 12:49:49 pm »
how can you suppress variable not used warning?
while I try different scenarios  I may have several unused variables and it annoys me to constantly see these warnings

Thaddy

  • Hero Member
  • *****
  • Posts: 16199
  • Censorship about opinions does not belong here.
Re: Suppressing warnings
« Reply #16 on: February 23, 2024, 01:01:02 pm »
If I smell bad code it usually is bad code and that includes my own code.

srvaldez

  • Full Member
  • ***
  • Posts: 117
Re: Suppressing warnings
« Reply #17 on: February 23, 2024, 01:54:54 pm »
that does not help me, I am not using Lazarus, just free Pascal compiler
I looked at the compiler options but none the options addresses my question

TRon

  • Hero Member
  • *****
  • Posts: 3650
Re: Suppressing warnings
« Reply #18 on: February 23, 2024, 02:11:40 pm »
that does not help me, I am not using Lazarus, just free Pascal compiler
I looked at the compiler options but none the options addresses my question

test program:
Code: Pascal  [Select][+][-]
  1. program test;
  2.  
  3. var
  4.   x : integer;
  5. begin
  6.   writeln('hello world');
  7. end.
  8.  

compilation:
Code: [Select]
$ fpc -B test.pas
Free Pascal Compiler version 3.2.2 [2021/05/16] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling test.pas
test.pas(4,3) Note: Local variable "x" not used
Linking test
6 lines compiled, 0.1 sec
1 note(s) issued

Show the message number:
Code: [Select]
$ fpc -B -vq test.pas
Free Pascal Compiler version 3.2.2 [2021/05/16] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others
(1002) Target OS: Linux for x86-64
(3104) Compiling test.pas
test.pas(4,3) Note: (5025) Local variable "x" not used
(9015) Linking test
(1008) 6 lines compiled, 0.0 sec
(1023) 1 note(s) issued

Note that that the message number is 5025

ignore a particular message on the commandline:
Code: [Select]
$ fpc -B -vm5025 test.pas
Free Pascal Compiler version 3.2.2 [2021/05/16] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling test.pas
Linking test
6 lines compiled, 0.0 sec

If you want to do it in code:
Code: Pascal  [Select][+][-]
  1. program test;
  2.  
  3. {$warn 5025 off}
  4.  
  5. var
  6.   x : integer;
  7. begin
  8.   writeln('hello world');
  9. end.
  10.  

which give the same result:
Code: [Select]
$ fpc -B test.pas
Free Pascal Compiler version 3.2.2 [2021/05/16] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling test.pas
Linking test
8 lines compiled, 0.1 sec

That was already written in the previous posts and the same information is also available at: Alphabetical listing of command line options for the command line and here for the warn directive (scroll down and note the mention of message numbers)
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

srvaldez

  • Full Member
  • ***
  • Posts: 117
Re: Suppressing warnings
« Reply #19 on: February 23, 2024, 02:17:42 pm »
thanks a million TRon :)
that's what I needed to know

PascalDragon

  • Hero Member
  • *****
  • Posts: 5764
  • Compiler Developer
Re: Suppressing warnings
« Reply #20 on: February 23, 2024, 10:18:36 pm »
I know that I'm not separating runtime/designtime code but that's the way I got such addons/plugins installed. I also read somewhere on these packages' repos that this is a Lazarus bug, not that important to me I just need to know how to disable such warnings.

It's not about separation between runtime/designtime. You should not use the “Other Units Searchpath” if the units are also part of a package and instead have your project reference the package in question instead.

The normal way to get additional information on a message/warning is to use -vq (which will issue the number of the message) and then use {$WARN XXX OFF} (were x is the actual number of the message) but if these messages are specific to Lazarus then I am not sure. I always though all messages are generated by the (fpc) compiler.

These specific messages are generated by Lazarus itself, so you can't use the compiler mechanisms to suppress these messages.

dbannon

  • Hero Member
  • *****
  • Posts: 3156
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Suppressing warnings
« Reply #21 on: February 23, 2024, 11:47:58 pm »
.... Contact the authors of the package and ask them to fix it. ....

In the case of KControls, I doubt TK would be willing to restructure the whole package to be honest.  But he might be more interested if we had an authoritative sounding and quite specific reason why its needed. Maybe something like "PascalDragan said .....".

So, PascalDragon, can you be specific about what bad thing can actually happen ?

I'd be willing to do the work and send it to him as a pull request, he's accepted a few minor ones from me in the past.

TK is mainly a Delphi user (but package works fine with FPC/Lazarus). Is this not a problem in Delphi ?

Davo

Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

TRon

  • Hero Member
  • *****
  • Posts: 3650
Re: Suppressing warnings
« Reply #22 on: February 24, 2024, 11:30:27 am »
thanks a million TRon :)
that's what I needed to know
You're welcome  :)

Happy coding !

These specific messages are generated by Lazarus itself, so you can't use the compiler mechanisms to suppress these messages.
Ah, ic. That is good to know. Thank you PascalDragon.

« Last Edit: February 24, 2024, 11:32:32 am by TRon »
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

 

TinyPortal © 2005-2018