Promote warnings to errors lazarus / 64-FPC development ---------------------------------------------------------------------- gidesa · 2024-04-01 11:04 Hello,  in Delphi you can "promote" warnings to errors (or ignore them, too). You can do that from the IDE, or with directives as: {$WARN   UNSAFE_CODE   ERROR} (other that ON or OFF). I think this is an useful feature, that could be added to FPC/Lazarus. ---------------------------------------------------------------------- dsiders · 2024-04-01 14:17 Quote from: gidesa on April 01, 2024, 01:04:42 pmHello,  in Delphi you can "promote" warnings to errors (or ignore them, too). You can do that from the IDE, or with directives as: {$WARN   UNSAFE_CODE   ERROR} (other that ON or OFF). I think this is an useful feature, that could be added to FPC/Lazarus. It already exists for some messages/identifiers: https://www.freepascal.org/docs-html/prog/progsu80.html ---------------------------------------------------------------------- Thaddy · 2024-04-01 14:38 You can compile with -Sew which means treat warnings as errors: this is the way fpc itself is compiled.(the compiler and the rtl, not the packages) You can also compile with -Sewh too: even hints will be treated as errors. The latter is a bit over the top, but compiling with -Sew is highly recommended. Note that in many cases, you want to turn off a certain warning, because -Sew is very strict. Sometimes too strict. FPC could do that long before Delphi could. IOW FPC can do a lot more and more precise than Delphi can. ---------------------------------------------------------------------- gidesa · 2024-04-01 15:31 Quote from: dsiders on April 01, 2024, 04:17:40 pm It already exists for some messages/identifiers: https://www.freepascal.org/docs-html/prog/progsu80.html Wow, thank you! I was confused because in Lazarus the page Options/Messages is similar to the Delphi one, but without the Error option. But they are very few. In Lazarus messages list there are many more possible warnings. ---------------------------------------------------------------------- gidesa · 2024-04-01 15:35 Quote from: Thaddy on April 01, 2024, 04:38:29 pmYou can compile with -Sew which means treat warnings as errors: this is the way fpc itself is compiled.(the compiler and the rtl, not the packages) You can also compile with -Sewh too: even hints will be treated as errors. The latter is a bit over the top, but compiling with -Sew is highly recommended. Note that in many cases, you want to turn off a certain warning, because -Sew is very strict. Sometimes too strict. FPC could do that long before Delphi could. IOW FPC can do a lot more and more precise than Delphi can. Thank you! By the way, the image is from Delphi XE2 of 2011. Maybe FPC had this feature before that 2011. ---------------------------------------------------------------------- Thaddy · 2024-04-01 15:58 since 2 series. So yes, way before 2011. ---------------------------------------------------------------------- gidesa · 2024-04-01 16:03 Quote from: Thaddy on April 01, 2024, 05:58:22 pm2002 Ok. But I see one difference: in Delphi -all- warnings can be selectively set on/off/error, with IDE or directives. In FPC all can be set on/off, but -only in IDE-. And only a limited group can be  set to on/off/error with directive. So in Delphi you have more fine grained control. ---------------------------------------------------------------------- Thaddy · 2024-04-01 16:05 There is no difference. In fpc you can turn of any particular warning or hint. Or all of them. so it is the opposite. FPC can even turn off notes: -Sewhn. all of these are governed by numbers, like {$warn 5024 off} but these numbers are easy to come by and that switch is for warnings, hints and notes. I - and others - already explained that on this forum for, well, since Methusalem. In Lazarus it can even be done through a dialog, where you can pick and choose and you do not have to rely on the numbers. The dialog is under project options|compiler|messages. You can turn off or on all hints, warnings and notes. But FreePascal can do even better, because it allows you to switch them off or on for just a tiny fragment of code, using {$push} and {$pop}, which has also be explained many times. The latter relies on the programmer, not the dialog settings, because these are global. And you can't do that in Delphi. ---------------------------------------------------------------------- gidesa · 2024-04-01 17:31 No, it's different. Please see,  in my first post  I am writing about "promote warns to errors" (and same in title, and with image if not clear the phrase...), Not about switching on/off *all* warns. You wrote on -Sew that promote *all* warns to errors, thanks, it's a starting point. Edit: I tried to use "error" in direcive for a generic warn, for example: {$Warn 5037 error} This works fine! Although not documented. So the IDE could be improved to display the 3 options for every warn: on, off, error. ---------------------------------------------------------------------- PascalDragon · 2024-04-07 20:37 Quote from: gidesa on April 01, 2024, 07:31:26 pmEdit: I tried to use "error" in direcive for a generic warn, for example: {$Warn 5037 error} This works fine! Although not documented. Did you really read the documentation?