On Fri, 21 Mar 2014 22:29:53 -0700 Jon Cruz <jon@...18...> wrote:
On Mar 21, 2014, at 9:42 PM, Krzysztof KosiĆski wrote:
2014-03-21 23:25 GMT+01:00 Johan Engelen <jbc.engelen@...2592...>:
Ouch..... It'd be great if some people could work on at least getting configure to work with -Werror.
-Werror should NEVER be enabled by default, as it is equivalent to explicitly disabling forward compatibility with compilers and libraries.
Actually...
Warnings as errors is generally considered as a very good practice for professional software houses. The recommendations and standard industry practices are usually to have it on by default and then turn it off for the specific cases where it is required.
In practice future-proofing the code is usually achieved by writing code that complies with the standards, and that works cross-platform. Occasionally third-party libs can get their headers wrapped up in other headers to proof them against warnings.
Given that I've seen this work with code originally written for Netware, it definitely can work with future proofing.
Dear Jon,
At Johan's suggestion the Makefile I wrote recently allows:
- Ordinary system builders to build without -Werror - Developers to build with -Werror on all files apart from 'naughty' ones. Those files are compiled without -Werror. This makes it hard to add new warnings to the code base.
I believe this approach, which is somewhat more aggressive than Johan's current approach will encourage good development practice like you say, whilst not impinging on others. The Makefile nags developers to address the 'naughty' files to help keep the numbers down.
Krzysztof re-iterates the points I raised with Johan about platform compatibility. When I was writing the Makefiles for 0.48.4 I tried -Werror and I noticed significantly more errors with newer gccs, with newer glibcs, with -D_FORTIFY_SOURCE=2 and with newer libraries. Going from Debian 7.4 to my normal platform added many more which wouldn't compile with -Werror. Getting to zero errors is only going to be possible on a reference platform.
I like the use of -Werror -Wno-error=XYZ, but I respectfully suggest that to maintain code quality these flags are only applied to certain 'naughty' files. In future on the reference platform all other files should be compiled with just -Werror.
You note that other projects wrap libraries which generate compiler warnings. This might work in our case but I believe even this is vulnerable to the vagaries of compiler and library versions.
In my forthcoming re-hash of the Naughty Step as I called it, I intend to support different options for different platforms. Although this doesn't help us to fix the warnings it might help us get an overview of the warnings people on different platforms/with different build options experience. At the moment I suspect many people with different platforms wouldn't know whether a warning is specific to them or if it is a general problem.
Regards,
Is.
PS. Johan, on gcc at least:
1. Change -W to -Wextra (-W is old-hat). 2. Remove -Werror=switch and -Werror=return-type (-Werror makes them redundant).