Recent

Author Topic: Prevent calling abstract methods  (Read 391 times)

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 257
Prevent calling abstract methods
« 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?

Thaddy

  • Hero Member
  • *****
  • Posts: 12887
Re: Prevent calling abstract methods
« Reply #1 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
« Last Edit: November 28, 2022, 10:07:27 am by Thaddy »
Who is responsable for that!! The caller or the callee.. Out! ya'll, NOW. In UTC time, please, so maybe Yesterday or tomorrow.

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 257
Re: Prevent calling abstract methods
« Reply #2 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.

jamie

  • Hero Member
  • *****
  • Posts: 5160
Re: Prevent calling abstract methods
« Reply #3 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.
The only true wisdom is knowing you know nothing

Bart

  • Hero Member
  • *****
  • Posts: 4920
    • Bart en Mariska's Webstek
Re: Prevent calling abstract methods
« Reply #4 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

Thaddy

  • Hero Member
  • *****
  • Posts: 12887
Re: Prevent calling abstract methods
« Reply #5 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.
Who is responsable for that!! The caller or the callee.. Out! ya'll, NOW. In UTC time, please, so maybe Yesterday or tomorrow.

PascalDragon

  • Hero Member
  • *****
  • Posts: 4951
  • Compiler Developer
Re: Prevent calling abstract methods
« Reply #6 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