Lazarus

Programming => General => Topic started by: Grahame Grieve on November 28, 2022, 08:33:13 am

Title: Prevent calling abstract methods
Post by: Grahame Grieve on November 28, 2022, 08:33:13 am
The compiler emits a warning when it detects an object being constructed that has abstract methods. I'd like to be able to make that an error, like I can in Delphi, but I can't see a way to escalate some warnings and treat them as errors (only turn them off). Or have I missed something?
Title: Re: Prevent calling abstract methods
Post by: Thaddy on November 28, 2022, 10:04:45 am
compile with -Sew which means treat warnings as errors The compiler itself is compiled with that option.
It seems that is the option you are looking for.
Code: Bash  [Select][+][-]
  1.       -Se<x>     Error options. <x> is a combination of the following:
  2.          <n> : Compiler halts after the <n> errors (default is 1)
  3.          h : Compiler also halts after hints
  4.          n : Compiler also halts after notes
  5.          w : Compiler also halts after warnings
Title: Re: Prevent calling abstract methods
Post by: Grahame Grieve on November 28, 2022, 11:18:46 am
But I have hundreds of other warnings, some that I don't know how to fix because I think they're wrong, and many are in the LCL itself. soo that's not an option for me.
Title: Re: Prevent calling abstract methods
Post by: jamie on November 28, 2022, 01:51:37 pm
Ha, We don't need any stinking warnings@!   

If memory servers. {%H-} or something like that, I can't remember now..

 but it's an insert you can put on the Declaration where the nefarious warnings are ignored.
Title: Re: Prevent calling abstract methods
Post by: Bart on November 28, 2022, 02:38:50 pm
That only makes the Lazarus IDE not show the warning in the messages window.
The compiler does nothing with that.

Bart
Title: Re: Prevent calling abstract methods
Post by: Thaddy on November 28, 2022, 03:27:41 pm
Indeed, {% X} means Lazarus IDE only, {$WARN <number> OFF} works in the sourcecode itself and can be very finely grained.
Title: Re: Prevent calling abstract methods
Post by: PascalDragon on November 30, 2022, 10:32:42 pm
The compiler emits a warning when it detects an object being constructed that has abstract methods. I'd like to be able to make that an error, like I can in Delphi, but I can't see a way to escalate some warnings and treat them as errors (only turn them off). Or have I missed something?

{$WARN CONSTRUCTING_ABSTRACT ERROR}

But I have hundreds of other warnings, some that I don't know how to fix because I think they're wrong, and many are in the LCL itself. soo that's not an option for me.

If you only put the -SeXXX in your project's options then these won't be propagated to other packages or the LCL.
TinyPortal © 2005-2018