Hi,

With the assistance of clang-tidy (*) and a bit of manual editing, I've 
replaced most uses of 
NULL with nullptr in .cpp files, and got to the point where all our CI targets 
are happy with -
Wzero-as-null-pointer-constant, which warns about most uses of NULL or 0 or 
FALSE instead 
of nullptr.

Consequently, I've also removed the Travis-CI target that had a #define NULL 
nullptr hack, 
and enabled -Wzero-as-null-pointer-constant in configure when supported by the 
compiler 
(at least gcc >= 4.8 and clang >= 5.0).

There are still remaining occurences of NULL that could be replaced (in #ifdef 
branch not 
tested, in macros, in function calls that take variadic arguments, etc....) , 
but that can be done 
later.

As this is a rather painful exercice (1146 files changed) which is very fragile 
to concurrent 
changes, I'd like to drop this in trunk ASAP if there's no opposition.

The branch with the work is at (be warned, among the most boring ever):
https://github.com/OSGeo/gdal/compare/trunk...rouault:convert_to_nullptr

Even

(*) sed "s/NULL/nullptr/g" is not an option, as there is a significant number 
of occurences of 
NULL being in a string (think to SQL statements).
clang-tidy works great, but as it does a true parsing of the code, you need to 
pass it the same 
-D and -I switches as the compiler would take. I guess there would perhaps be a 
way of 
creating a CXX script that could be used as a fake compiler and would redirect 
to clang-tidy.

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to