Compiler Warnings Practices

Discussions center on the importance of enabling all compiler warnings (e.g., -Wall, -Wextra, -Weverything), treating them as errors with -Werror, and best practices for handling them in C/C++ codebases to prevent bugs.

📉 Falling 0.5x Programming Languages
3,442
Comments
19
Years Active
5
Top Authors
#5602
Topic ID

Activity Over Time

2008
5
2009
19
2010
71
2011
81
2012
89
2013
166
2014
201
2015
170
2016
260
2017
295
2018
144
2019
222
2020
228
2021
341
2022
267
2023
381
2024
205
2025
267
2026
32

Keywords

GCC LTS MSVC lib.rs warnings compiler warning errors compilers clang code warn gcc wall

Sample Comments

mytailorisrich Jul 20, 2021 View on HN

The compiler can issue warnings for this.This os why in C it is a good practice to enable all compiler warnings and to have the compiler treat warnings as errors.

sangnoir Sep 24, 2015 View on HN

How about "taking heed of compiler warnings" as suggested by Linus? it's niether expensive nor mentally taxing

braveo Nov 17, 2016 View on HN

I'll have to check when I get home, but I'm fairly certain you're purposefully suppressing the compilers warnings here. That's not a good way to make your argument about the compiler not being able to warn you about problems.

gpvos Apr 19, 2017 View on HN

It shouldn't be too hard for compilers to warn about this, I think.

rowanG077 Sep 12, 2020 View on HN

I don't feel it's so bad. You have a a specific flag to tell the compiler to show warnings if you have any.

noamsml Feb 26, 2016 View on HN

Nice. These sorts of warnings are why it's worth investing the extra effort to enable -Werror in your codebase if you can.

Jare Jan 2, 2023 View on HN

"Treat warnings as errors" is a standard best practice.

Gibbon1 Jan 2, 2023 View on HN

Treat warnings as errors is terrible practice.

hermitdev Apr 8, 2022 View on HN

Yes! Was going to suggest much the same: crank up the warnings and treat them as errors!

alpaca128 Dec 21, 2021 View on HN

In which case a warning would also do the trick, unless the compiler produces so many warnings that people stop caring.