Recent

Author Topic: Suppressing warnings  (Read 2923 times)

nimble2010

  • New Member
  • *
  • Posts: 14
Suppressing warnings
« on: February 22, 2024, 01:24:12 pm »
Hello there!

I noticed that there are some warnings/notes that are missing in the Project Options "Messages" panel and that makes it difficult to suppress them, there are also certain warnings that I couldn't get their ids to suppress them using the warn directive like the following:

Code: Pascal  [Select][+][-]
  1. Messages, Warnings: 5
  2. Warning: other unit files search path (aka unit path) of "KControlsLaz 1.7.3" contains "xxx\Plugins\KControls\source", which belongs to package "KControlsBase"
  3.  
  4. Warning: other unit files search path (aka unit path) of "GLScene_DesignTime 1.0" contains "xxx\Plugins\GLSceneLCL\Source", which belongs to package "GLScene_RunTime"
  5.  
  6. Warning: other unit files search path (aka unit path) of "GLScene_RunTime 1.0" contains "xxx\Plugins\GLSceneLCL\Source\Basis", which belongs to package "GLScene_DesignTime"
  7.  
  8. Warning: other sources path of package "lnetbase 0.6.6" contains directory "..\lib" which is already in the unit search path.

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.
« Last Edit: February 22, 2024, 01:26:11 pm by nimble2010 »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Suppressing warnings
« Reply #1 on: February 22, 2024, 01:55:02 pm »
I just need to know how to disable such warnings.
Easiest way, by installing packages like they should be installed.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

TRon

  • Hero Member
  • *****
  • Posts: 3623
Re: Suppressing warnings
« Reply #2 on: February 22, 2024, 01:56:23 pm »
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.
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

nimble2010

  • New Member
  • *
  • Posts: 14
Re: Suppressing warnings
« Reply #3 on: February 22, 2024, 02:19:45 pm »

nimble2010

  • New Member
  • *
  • Posts: 14
Re: Suppressing warnings
« Reply #4 on: February 22, 2024, 02:27:25 pm »
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.

Yes but even if I got the message id, how would I use warn? It's a config issue, there are two packages that share the same paths, one is dependent on another:

Package config 1:

<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
  <Package Version="5">
    <Name Value="GLScene_RunTime"/>
    <AddToProjectUsesSection Value="True"/>
    <CompilerOptions>
      <Version Value="11"/>
      <SearchPaths>
        <IncludeFiles Value="../Source"/>
        <OtherUnitFiles Value="../Source;../Source/Basis;../Source/FileFormats;../Source/Shaders;../Source/GameAPIs;../Source/ScriptingAPIs;../Source/Plateform;../Source/DesignTime"/>
        <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
      </SearchPaths>

Package config 2:

<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
  <Package Version="5">
    <Name Value="GLScene_DesignTime"/>
    <Type Value="DesignTime"/>
    <AddToProjectUsesSection Value="True"/>
    <CompilerOptions>
      <Version Value="11"/>
      <SearchPaths>
        <IncludeFiles Value="../Source"/>
        <OtherUnitFiles Value="../Source;../Source/Basis;../Source/DesignTime;../Source/Plateform;../Source/GameAPIs;../Source/Shaders;../Source/SoundVideoAPIs;../Source/FileFormats"/>
        <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
        <SrcPath Value="../Lazarus"/>
      </SearchPaths>

"GLScene_RunTime" is a required package for "GLScene_DesignTime".
« Last Edit: February 22, 2024, 02:29:00 pm by nimble2010 »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Suppressing warnings
« Reply #5 on: February 22, 2024, 02:37:53 pm »
I just need to know how to disable such warnings.
Easiest way, by installing packages like they should be installed.

Which is what I did:
https://sourceforge.net/p/glscene/wiki/Lazarus%20Installation/
https://github.com/kryslt/KControls/issues/25
Actually I was meaning by OPM, like I show for the KControl package on screenshot
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

nimble2010

  • New Member
  • *
  • Posts: 14
Re: Suppressing warnings
« Reply #6 on: February 22, 2024, 02:46:29 pm »
I just need to know how to disable such warnings.
Easiest way, by installing packages like they should be installed.

Which is what I did:
https://sourceforge.net/p/glscene/wiki/Lazarus%20Installation/
https://github.com/kryslt/KControls/issues/25
Actually I was meaning by OPM, like I show for the KControl package on screenshot

I did install the packages from the OPM originally.

Thaddy

  • Hero Member
  • *****
  • Posts: 16162
  • Censorship about opinions does not belong here.
Re: Suppressing warnings
« Reply #7 on: February 22, 2024, 02:47:58 pm »
Suppressing warnings and hints is not difficult at all.
Compile with -vq option. That adds the warning number to the compiler output. Then either in code or by compiler option disable them:
Code: Pascal  [Select][+][-]
  1. {$warn < the number > off}
or on the command line -vw<the number>- (the minus sign)
This is a local directive so can be very finely grained with {$push}{$pop}

All of this is in the documentation of course.
« Last Edit: February 22, 2024, 02:57:37 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

TRon

  • Hero Member
  • *****
  • Posts: 3623
Re: Suppressing warnings
« Reply #8 on: February 22, 2024, 05:07:19 pm »
Compile with -vq option. That adds the warning number to the compiler output. Then either in code or by compiler option disable them:
Code: Pascal  [Select][+][-]
  1. {$warn < the number > off}
or on the command line -vw<the number>- (the minus sign)
Huh ?

Is that a new feature or something  I simply did not know ? (using -vwXXX- at 3.2.2 seem to suppress any output from the compiler for me (except for the FPC header))

I ask because from the manual I got the notion that -vm is used to (globally) suppress a specific warning (and is what I have been using all this time)

@nimble2010:
You can use the global -vm switch and supply the message numbers in order to suppress the warnings. But it depends on when it is happening. I do not know to suppress when you get those message during installation of the packages (other than mentioned by Thaddy in the source-code)
« Last Edit: February 22, 2024, 05:12:50 pm by TRon »
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

Thaddy

  • Hero Member
  • *****
  • Posts: 16162
  • Censorship about opinions does not belong here.
Re: Suppressing warnings
« Reply #9 on: February 22, 2024, 08:20:46 pm »
Is that a new feature or something  I simply did not know ?
You simply did not know and that is because you did not care about examining the documentation.

Note that retrieving the numbers is not obvious to everyone.
I use 6060 every day thanks to Jonas. (Case ending, trunk )
« Last Edit: February 22, 2024, 08:28:17 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

TRon

  • Hero Member
  • *****
  • Posts: 3623
Re: Suppressing warnings
« Reply #10 on: February 22, 2024, 08:27:29 pm »
@Thaddy:

My reaction was specifically regarding the following part of your post:
or on the command line -vw<the number>- (the minus sign)

That is not documented at https://www.freepascal.org/docs-html/user/userap1.html and as said for me suppresses all the output from the compiler for me.
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

Thaddy

  • Hero Member
  • *****
  • Posts: 16162
  • Censorship about opinions does not belong here.
Re: Suppressing warnings
« Reply #11 on: February 22, 2024, 08:30:13 pm »
I will try to explain the details tomorrow, but it is in the documentation, otherwise I did not know about it... ;D

Didn't I do that yet? either on the forum or the wiki? Likely YES. (But I am old)
If you use the Lazarus ide there is even a menu for it.
« Last Edit: February 22, 2024, 08:37:31 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

TRon

  • Hero Member
  • *****
  • Posts: 3623
Re: Suppressing warnings
« Reply #12 on: February 22, 2024, 08:35:22 pm »
Well, if you did then I am sorry to say I did not had the pleasure to read it  :)

Code: [Select]
$ fpc -B -vq listing.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 listing.pas
(3104) Compiling ./packages/jsontools.pas
(1010) Writing Resource String Table file: jsontools.rsj
(3104) Compiling ./packages/helper.jsontools.pas
(3104) Compiling ./packages/zstream.pp
(1010) Writing Resource String Table file: zstream.rsj
(1010) Writing Resource String Table file: helper.jsontools.rsj
(3104) Compiling ./packages/universal.solar.pas
universal.solar.pas(329,35) Warning: (5037) Variable "aStream" does not seem to be initialized
(3104) Compiling ./packages/universal.gcollection.pas
(9015) Linking listing
(1008) 4194 lines compiled, 0.4 sec
(1021) 1 warning(s) issued

Code: [Select]
$fpc -B -vw5037- listing.pas
Free Pascal Compiler version 3.2.2 [2021/05/16] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others

Code: [Select]
fpc -B -vm5037 listing.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 listing.pas
Compiling ./packages/jsontools.pas
Writing Resource String Table file: jsontools.rsj
Compiling ./packages/helper.jsontools.pas
Compiling ./packages/zstream.pp
Writing Resource String Table file: zstream.rsj
Writing Resource String Table file: helper.jsontools.rsj
Compiling ./packages/universal.solar.pas
Compiling ./packages/universal.gcollection.pas
Linking listing
4194 lines compiled, 0.4 sec
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

Thaddy

  • Hero Member
  • *****
  • Posts: 16162
  • Censorship about opinions does not belong here.
Re: Suppressing warnings
« Reply #13 on: February 22, 2024, 08:42:34 pm »
;) look at the images I attached....
But I prefer that to do that with other editors too, like Geany, which works.
« Last Edit: February 22, 2024, 08:48:45 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

wp

  • Hero Member
  • *****
  • Posts: 12459
Re: Suppressing warnings
« Reply #14 on: February 22, 2024, 11:53:51 pm »
there are two packages that share the same paths, one is dependent on another:
Independently of your question, this is a situation which should be avoided because it can break installation of the designtime package. Try to move the two packages, as well as their output directories, into separate directories. Of course, a bit frustrating when it's a third-party package you have no control of... Contact the authors of the package and ask them to fix it. When they do not respond just fix your local copy, there is relatively little risk that you'll have to do this again for an update because otherwise the authors would have responded.

The other option is to ignore the warning. Keep your fingers crossed...

 

TinyPortal © 2005-2018