[gdal-dev] MSVC warnings changes

Frank Warmerdam warmerdam at pobox.com
Fri Feb 11 17:23:51 EST 2011


Folks,

I have spent several hours today cleaning up warnings when building with
Microsoft Visual C++.

The first step was to move warning suppression out of gdal/port/cpl_port.h
and instead passing warning suppression via the compiler commandline line.
This is accomplished by setting of the WARNFLAGS macro in nmake.opt with
a warning level (/W4 now) and a set of specific warnings to be disabled
(using /wd4127, etc).  Moving the disabling out of cpl_port.h is important
because it means GDAL policy of disabling some warnings will not impact
applications including gdal.h.

The warning I have disabled are things I feel are reasonable practice and
not worth seeing as warnings.  Mostly this is the same as the warnings
disabled in cpl_port.h, but I have add a few including warnings related
to signed/unsigned comparison mismatches.  These drive me nuts and have not
(for me) yet lead to identifying a real error.

I have also introduced the SOFTWARNFLAGS macro.  This disables a bunch more
warnings, and is used in some of the submakefiles building code from external
sources that we can't practically alter.  This includes stuff like zlib,
and libjpeg.

I have made a variety substantial pass over the GDAL source tree building
with MS Visual Studio 2008 Express Edition and trying to adjust the code to
clean away warnings and in a few cases adding extra local warning disablers
either in makefiles or using the pragma in the code.   These changes can
mostly be seen in these commits:

   http://trac.osgeo.org/gdal/changeset/21684
   http://trac.osgeo.org/gdal/changeset/21680

The main warnings I'm still aware of are related to the MITAB and AVCE00
libraries.  These changes need to be upstreamed and were sufficiently involved
that I put them off.   Beyond that I was able to get a pretty much warning
free build on /W4.

Going forward I am hoping we can balance appropriate choice of warnings
to suppress globally and adjustments to the code to keep our windows
build warning-clean.  Hopefully this will help us be more vigilant  in
addressing new warnings that do pop up.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the gdal-dev mailing list