r/ProgrammerHumor • • 18h ago

Meme checkBuildSettings

Post image
3.0k Upvotes

73 comments sorted by

View all comments

Show parent comment

16

u/PrincessRTFM 6h ago

For years, my argument has been that if the warning is correct then it should be fixed, and if it isn't then it should be explicitly suppressed at that location. I don't give a fuck that it's "just a warning", warnings exist for a damn reason. Either the compiler is right and that code isn't doing what I expected, or I know better and I should save myself and any future maintainers effort by adding a suppression and explanation. The only reason I don't set all warnings to be errors is because some of them trigger while I'm still writing my code and I want to be able to test in stages.

7

u/Prawn1908 4h ago

Exactly. Warnings either get corrected or locally suppressed with a comment right above the #pragma explaining exactly why it's safe.

9

u/PrincessRTFM 3h ago

my favourite is the way rust does it: #[expect(whatever)] will emit a warning if no warning of category whatever is emitted. if you refactor things and that warning is no longer relevant, you need to remove the suppression, and using expect instead of allow is perfect for that.