* * *

Author Topic: Unable to disable Warnings  (Read 2014 times)

Paulo França Lacerda

  • New member
  • *
  • Posts: 44
Unable to disable Warnings
« on: October 08, 2016, 03:19:23 pm »
I'd like to prevent Warnings (all of them) from being shown in the Messages window at compile-time.

Tried unchecking
absolutely all items at:
Project Options -> Compiler Options -> Verbosity -> Verbosity during compilation
Didn't work.

Tried unchecking every single warning-related item at:
Project Options -> Compiler Options -> Messages -> Compiler messages
Didn't work either.

Any advices?
Lazarus 1.6.0.4 on FreePascal 3.0
Windows 7 32-bit

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 626
    • Burdjia
Re: Unable to disable Warnings
« Reply #1 on: October 15, 2016, 12:07:09 pm »
I'd like to prevent Warnings (all of them) from being shown in the Messages window at compile-time. (...)
The way to do it is to write good code.  Warnings are potential bugs in most cases, that's why you can't deactivate all them.

Paulo França Lacerda

  • New member
  • *
  • Posts: 44
Re: Unable to disable Warnings
« Reply #2 on: October 15, 2016, 02:08:15 pm »
I'd like to prevent Warnings (all of them) from being shown in the Messages window at compile-time. (...)
The way to do it is to write good code.  Warnings are potential bugs in most cases, that's why you can't deactivate all them.
If there is an option for disabling it, it should work. Shouldn't it?
If the warnings messages were not supposed to be disabled (as you state), no option would have been provided, then.
Lazarus 1.6.0.4 on FreePascal 3.0
Windows 7 32-bit

Thaddy

  • Hero Member
  • *****
  • Posts: 3971
Re: Unable to disable Warnings
« Reply #3 on: October 15, 2016, 03:25:31 pm »
Warnings indicate bad code. You should resolve them unless you know they are harmless.
In 99% of the cases they are NOT harmless and you made a mistake.
But the Lazarus IDE doesn't seem to follow the real compiler here.
Try to compile from the commandline with fpc and turn warnings off on the commandline -vw-
« Last Edit: October 15, 2016, 03:28:50 pm by Thaddy »
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

Bart

  • Hero Member
  • *****
  • Posts: 2671
    • Bart en Mariska's Webstek
Re: Unable to disable Warnings
« Reply #4 on: October 15, 2016, 04:15:36 pm »
Compile with -v0 ?  (0 : Show nothing (except errors))
But, as others stated, this is really a bad idea.

Bart

Thaddy

  • Hero Member
  • *****
  • Posts: 3971
Re: Unable to disable Warnings
« Reply #5 on: October 15, 2016, 04:21:35 pm »
Compile with -v0 ?  (0 : Show nothing (except errors))
But, as others stated, this is really a bad idea.

Bart
I didn't know that -v0 ;) Tnx Bart ;) Is that documented? Than I overlooked it.
And {$WARNINGS OFF} in your lpr file also seems to work for your own code.

Anyway, the compiler itself is compiled even stricter: with -Sew which means "treat warnings as errors".
There is a reason for that.....

The compiler devs know that modesty has priority over arrogance when proper code is concerned, so they force themselves to solve all possible issues the compiler already knows.

« Last Edit: October 15, 2016, 04:27:44 pm by Thaddy »
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

Bart

  • Hero Member
  • *****
  • Posts: 2671
    • Bart en Mariska's Webstek
Re: Unable to disable Warnings
« Reply #6 on: October 15, 2016, 04:32:45 pm »
I didn't know that -v0 ;) Tnx Bart ;) Is that documented? Than I overlooked it.

Code: [Select]
C:\Users\Bart>fpc -h | grep --after-context=12 "verbose"
  -v<x>  Be verbose. <x> is a combination of the following letters:
      e : Show errors (default)       0 : Show nothing (except errors)
      w : Show warnings               u : Show unit info
      n : Show notes                  t : Show tried/used files
      h : Show hints                  c : Show conditionals
      i : Show general info           d : Show debug info
      l : Show linenumbers            r : Rhide/GCC compatibility mode
      s : Show time stamps            q : Show message numbers
      a : Show everything             x : Show info about invoked tools
      b : Write file names messages   p : Write tree.log with parse tree
          with full path              v : Write fpcdebug.txt with
      z : Write output to stderr          lots of debugging info
      m<x>,<y> : Do not show messages numbered <x> and <y>

Bart

Thaddy

  • Hero Member
  • *****
  • Posts: 3971
Re: Unable to disable Warnings
« Reply #7 on: October 15, 2016, 05:08:30 pm »
Mea culpa,mea maxima culpa ;) , Bart
otoh, I disable warnings by number. When - I think - needed. O:-)
« Last Edit: October 15, 2016, 05:10:40 pm by Thaddy »
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

Paulo França Lacerda

  • New member
  • *
  • Posts: 44
Re: Unable to disable Warnings
« Reply #8 on: October 15, 2016, 05:11:57 pm »
...But the Lazarus IDE doesn't seem to follow the real compiler here.
Yes, that's my goal: suppress the messages on the IDE.
The command line messages don't bother me.
Lazarus 1.6.0.4 on FreePascal 3.0
Windows 7 32-bit

Thaddy

  • Hero Member
  • *****
  • Posts: 3971
Re: Unable to disable Warnings
« Reply #9 on: October 15, 2016, 05:52:37 pm »
Well, I told you already that {$WARNINGS OFF} in the project file ( project| view source)
But listen and read the comments: you are not supposed to ignore warnings!
If you do you have a 1% chance of not being an idiot.

I just tested that solution on code here on the forum from this week that is properly written but still generates a warning on my machine:
Code: Pascal  [Select]
  1. program noneedtoknow;
  2. {$mode objfpc}{$H+}
  3. {$WARNINGS OFF}  // here the stupid cocky programmer kicks in..... don't ever do that....but you can....sigh
  4.  
  5. uses
  6.  
You better show your code... all of it... and we will nit-pick all over it to show you are the 1% if we can not find anything stupid, ok?
My bet is 10 seconds.
https://www.youtube.com/watch?v=Uz1Jwyxd4tE for good measure  8-)

You can also simply right-click on the messages tab and close the message window... Also not recommended,
WHY??????
« Last Edit: October 15, 2016, 06:29:15 pm by Thaddy »
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

Bart

  • Hero Member
  • *****
  • Posts: 2671
    • Bart en Mariska's Webstek
Re: Unable to disable Warnings
« Reply #10 on: October 15, 2016, 07:20:42 pm »
Go ahead, please be stupid.

Go to Project Options -> Compiler Options -> Custom Options.
In the memo type "-v0" without the quotes.

Now only errors (no warnings or hints) are being output by the compiler (and therefore shown in Messages window).
I've tested it and it works.
Then I deleted that option as fast as I could, because I am a lousy programmer and want all the hints and warnings to show up.

The command line messages don't bother me.

Lazarus IDE just pipes the "commandline" messages and filters them.

Bart

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus