[gdal-dev] Warning-free builds :-)
Even Rouault
even.rouault at spatialys.com
Thu Oct 29 09:51:17 PDT 2015
Hi,
We've achieved an important and symbolic milestone that will mean something to
developers: most of our (Unix) builds are warning free (for the library +
utilities) ! That is they pass with -Wall -Wextra -Werror compiler options.
Not bad for a ~ 400 K effective line of code project ( ~ 800 K, with white
lines + comments).
So celebrate that and please keep it that way now ! And thanks to all those
who have helped achieving this.
More specifically ./configure will enable -Wall -Wextra and other warnings (-
Winit-self -Wunused-parameter -Wmissing-prototypes -Wmissing-declarations -
Wformat -Werror=format-security -Wno-format-nonliteral -Werror=vla -
Werror=declaration-after-statement -Wno-clobbered -Wunused-private-field), but
*not* with -Werror (-Werror means that any warning will be interpreted as an
error and fail the build).
I haven't dared enabling -Werror by default due to the almost infinite possible
configurations (choice of dependencies x choice of compilers) that make it
impossible to be sure there isn't one that will throw some warning. I was
wondering if we couldn't have a --enable-werror option that could default to
yes for --enable-debug builds (and no for regular builds), so that developers
have no excuse to commit warnings ?
Trick to use -Werror: "make USER_DEFS=-Werror". You can also do CPPFLAGS=-
Werror ./configure , but that may interfere with the detection of some
libraries.
Most Travis CI builds have already -Werror enabled :
- the default one : https://travis-ci.org/OSGeo/gdal (thus github pull
requests will be affected by that too)
- and at https://travis-ci.org/rouault/gdal_coverage/builds :
* trunk_with_coverage
* python3
* trunk_travis_macosx
* trunk_mingw
* trunk_mingw_w64
* trunk_android
* trunk_gcc4.8_stdc11
so everything but trunk_gcc5.2_sanitize since gcc 5.2 warns about our own
deprecated symbols for some reason
So even if your configuration is warning free, it is important to keep an eye
on the above links (or IRC bot messages).
Making sure we don't hit warnings is important since it can save bugs in
practice. For example, the class of bugs to which one reported yesterday
(https://trac.osgeo.org/gdal/ticket/6183) belongs to will no longer be
possible with the added -Wmissing-prototypes and -Wmissing-declarations.
Even
PS: I had issues with most proprietary SDK whose headers are not warning free.
A trick is to create a .h wrapper on top of which you put this before
including the SDK headers, so as to shut all warnings for the rest of the file
:
#ifdef HAVE_GCC_SYSTEM_HEADER
#pragma GCC system_header
#endif
(will work too with clang)
See
https://svn.osgeo.org/gdal/trunk/gdal/ogr/ogrsf_frmts/filegdb/filegdbsdk_headers.h
--
Spatialys - Geospatial professional services
http://www.spatialys.com
More information about the gdal-dev
mailing list