4 ms·
Yep. I'd add that if it's a warning you're absolutely certain of, use the warning control pragmas to suppress them, and document why the warning's suppressed. K
by Sanddancer 10y ago
Yep. I'd add that if it's a warning you're absolutely certain of, use the warning control pragmas to suppress them, and document why the warning's suppressed. Keep the compiler output clean so you can see where you need to examine.
- TeMPOraL 10y agoExactly. That's what I meant by "ignore"; "suppress" was the word I was looking for.
- pacaro 10y agoYup. I'm a big fan of -Wall -Wextra -Werror If these options are set before you write any code, then these problems don't arise.
- yoklov 10y agoWorth noting you should probably disable -Werror for distribution if you expect users to compile your code. They aren't going to fix your error for you and you can't know what warnings will be added to future compilers, nor what previous compiler versions marked as errors. Among many other people saying the same thing see [0] if you don't trust me. Also IMO you often want to explicitly disable a few of those from -Wall and -Wextra -- Looking at the last c++ project I wrote, I turned off a few things like `-Wno-unused-parameter` for example. [0]: http://blog.schmorp.de/2016-02-27-tidbits-for-the-love-of-god-dont-use-werror.html http://blog.schmorp.de/2016-02-27-tidbits-for-the-love-of-go...
- pacaro 10y agoAbsolutely agree. As you get further into a project you tend to need subtler tools. But for the rough work when starting out, my preference is to be stricter, which can be relaxed as necessary, rather than starting out lax and reaching a point where tightening becomes Sisyphean.
- daira 10y agoZcash, for example, is built with `-Werror` (edit: not `-Wall`, but we're working on that). So this is absolutely feasible on a Bitcoin-derived codebase.
- aaronmdjones 10y agoOr if you're using clang you can just -Weverything Which does actually turn on all warnings (so you'll probably want to add things like -Wno-unused -Wno-padded). Under gcc, '-Wall -Wextra -Wpedantic' does not enable all warnings. There are still more than 40 flags you have to give if you really want all of them. The reason why boggles my mind to this day.