3 ms·
In a large codebase with many warnings (incl from dependencies which you might not have control over), the difference between a compiler warning and hard error
by nevi-me 4y ago
In a large codebase with many warnings (incl from dependencies which you might not have control over), the difference between a compiler warning and hard error is significant.
- DannyBee 4y agoIt is easily made a hard error using -Werror, or you can even just make this an error if you don't want all warnings to be errors: clang++ test.cc -std=c++17 -Werror=dangling-gsl. test.cc:7:29: error: object backing the pointer will be destroyed at the end of the full-expression [-Werror,- Wdangling-gsl] std::string_view sv = s + "World\n"; ^~~~~~~~~~~~~ It is pretty standard in large codebases in any language to carefully choose sets of warnings and errors. I do think Rust has lots to offer, but i think the eternal argument here about what the compiler lets you do vs not is not likely to be a winning one with the C++ developers you see who don't want to move over.
- kllrnohj 4y ago`-Wall -Werror -Wextra` is the first thing to add to any project's cpp flags. And then selectively -Wno-whatever the stuff you don't really care about or is too annoying to go fix if it's an existing codebase