diff --git a/.github/workflows/code_checks.yml b/.github/workflows/code_checks.yml index ce3afb386432..9d74314e54e7 100644 --- a/.github/workflows/code_checks.yml +++ b/.github/workflows/code_checks.yml @@ -60,6 +60,9 @@ jobs: - name: Detect suspicious char digit zero run: ./scripts/detect_suspicious_char_digit_zero.sh + - name: Detect missing includes + run: ./scripts/detect_missing_include.sh + - name: Shellcheck run: shellcheck -e SC2086,SC2046,SC2164,SC2054 $(find . -name '*.sh' -a -not -name ltmain.sh -a -not -wholename "./autotest/*" -a -not -wholename "./.github/*") diff --git a/alg/gdal_rpc.cpp b/alg/gdal_rpc.cpp index c62c15dfa159..0b3844d388d0 100644 --- a/alg/gdal_rpc.cpp +++ b/alg/gdal_rpc.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include "cpl_conv.h" diff --git a/alg/gdalrasterize.cpp b/alg/gdalrasterize.cpp index b883cd9f82d0..ef9cfc39dcbe 100644 --- a/alg/gdalrasterize.cpp +++ b/alg/gdalrasterize.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include diff --git a/alg/gdaltransformer.cpp b/alg/gdaltransformer.cpp index 4481d14b82a8..ff62005cb398 100644 --- a/alg/gdaltransformer.cpp +++ b/alg/gdaltransformer.cpp @@ -41,6 +41,7 @@ #include #include +#include #include #include "cpl_conv.h" diff --git a/alg/marching_squares/square.h b/alg/marching_squares/square.h index 21c9956bc8a6..4b9f19e3eb35 100644 --- a/alg/marching_squares/square.h +++ b/alg/marching_squares/square.h @@ -28,6 +28,7 @@ #ifndef MARCHING_SQUARE_SQUARE_H #define MARCHING_SQUARE_SQUARE_H +#include #include #include #include @@ -39,15 +40,15 @@ namespace marching_squares { struct Square { // Bit flags to determine borders around pixel - static const uint8_t NO_BORDER = 0; // 0000 0000 - static const uint8_t LEFT_BORDER = 1 << 0; // 0000 0001 + static const uint8_t NO_BORDER = 0; // 0000 0000 + static const uint8_t LEFT_BORDER = 1 << 0; // 0000 0001 static const uint8_t LOWER_BORDER = 1 << 1; // 0000 0010 static const uint8_t RIGHT_BORDER = 1 << 2; // 0000 0100 static const uint8_t UPPER_BORDER = 1 << 3; // 0000 1000 // Bit flags for marching square case - static const uint8_t ALL_LOW = 0; // 0000 0000 - static const uint8_t UPPER_LEFT = 1 << 0; // 0000 0001 + static const uint8_t ALL_LOW = 0; // 0000 0000 + static const uint8_t UPPER_LEFT = 1 << 0; // 0000 0001 static const uint8_t LOWER_LEFT = 1 << 1; // 0000 0010 static const uint8_t LOWER_RIGHT = 1 << 2; // 0000 0100 static const uint8_t UPPER_RIGHT = 1 << 3; // 0000 1000 @@ -107,27 +108,27 @@ struct Square assert(lowerLeft.y == lowerRight.y); assert(lowerLeft.x == upperLeft.x); assert(lowerRight.x == upperRight.x); - assert(!split || nanCount == 0); + assert(!split || nanCount == 0); } - Square upperLeftSquare() const - { + Square upperLeftSquare() const + { assert(!std::isnan(upperLeft.value)); return Square( - upperLeft, upperCenter(), + upperLeft, upperCenter(), leftCenter(), center(), - (std::isnan(upperRight.value) ? RIGHT_BORDER: NO_BORDER) - | (std::isnan(lowerLeft.value) ? LOWER_BORDER : NO_BORDER), true); + (std::isnan(upperRight.value) ? RIGHT_BORDER: NO_BORDER) + | (std::isnan(lowerLeft.value) ? LOWER_BORDER : NO_BORDER), true); } Square lowerLeftSquare() const - { + { assert(!std::isnan(lowerLeft.value)); return Square( - leftCenter(), center(), + leftCenter(), center(), lowerLeft, lowerCenter(), - (std::isnan(lowerRight.value) ? RIGHT_BORDER: NO_BORDER) - | (std::isnan(upperLeft.value) ? UPPER_BORDER : NO_BORDER), true); + (std::isnan(lowerRight.value) ? RIGHT_BORDER: NO_BORDER) + | (std::isnan(upperLeft.value) ? UPPER_BORDER : NO_BORDER), true); } Square lowerRightSquare() const @@ -137,7 +138,7 @@ struct Square center(), rightCenter(), lowerCenter(), lowerRight, (std::isnan(lowerLeft.value) ? LEFT_BORDER: NO_BORDER) - | (std::isnan(upperRight.value) ? UPPER_BORDER : NO_BORDER), true); + | (std::isnan(upperRight.value) ? UPPER_BORDER : NO_BORDER), true); } Square upperRightSquare() const @@ -147,20 +148,20 @@ struct Square upperCenter(), upperRight, center(), rightCenter(), (std::isnan(lowerRight.value) ? LOWER_BORDER: NO_BORDER) - | (std::isnan(upperLeft.value) ? LEFT_BORDER : NO_BORDER), true); - } + | (std::isnan(upperLeft.value) ? LEFT_BORDER : NO_BORDER), true); + } double maxValue() const { assert(nanCount==0); - return std::max(std::max(upperLeft.value, upperRight.value), + return std::max(std::max(upperLeft.value, upperRight.value), std::max(lowerLeft.value, lowerRight.value)); } - + double minValue() const { assert(nanCount==0); - return std::min(std::min(upperLeft.value, upperRight.value), + return std::min(std::min(upperLeft.value, upperRight.value), std::min(lowerLeft.value, lowerRight.value)); } @@ -277,7 +278,7 @@ struct Square // bitwise AND to test which borders we have on the square if ( ( border & borders ) == 0 ) continue; - + // convention: for a level = L, store borders for the previous level up to // (and including) L in the border of level "L". // For fixed sets of level, this means there is an "Inf" slot for borders of the highest level @@ -353,7 +354,7 @@ struct Square ValuedPoint center() const { - return ValuedPoint( + return ValuedPoint( .5*(upperLeft.x + lowerRight.x), .5*(upperLeft.y + lowerRight.y), ( (std::isnan(lowerLeft.value) ? 0 : lowerLeft.value) @@ -365,9 +366,9 @@ struct Square ValuedPoint leftCenter() const { - return ValuedPoint( + return ValuedPoint( upperLeft.x, - .5*(upperLeft.y + lowerLeft.y), + .5*(upperLeft.y + lowerLeft.y), std::isnan(upperLeft.value) ? lowerLeft.value : (std::isnan(lowerLeft.value) ? upperLeft.value : .5*(upperLeft.value + lowerLeft.value))); @@ -375,9 +376,9 @@ struct Square ValuedPoint lowerCenter() const { - return ValuedPoint( + return ValuedPoint( .5*(lowerLeft.x + lowerRight.x), - lowerLeft.y, + lowerLeft.y, std::isnan(lowerRight.value) ? lowerLeft.value : (std::isnan(lowerLeft.value) ? lowerRight.value : .5*(lowerRight.value + lowerLeft.value))); @@ -385,9 +386,9 @@ struct Square ValuedPoint rightCenter() const { - return ValuedPoint( + return ValuedPoint( upperRight.x, - .5*(upperRight.y + lowerRight.y), + .5*(upperRight.y + lowerRight.y), std::isnan(lowerRight.value) ? upperRight.value : (std::isnan(upperRight.value) ? lowerRight.value : .5*(lowerRight.value + upperRight.value))); @@ -395,9 +396,9 @@ struct Square ValuedPoint upperCenter() const { - return ValuedPoint( + return ValuedPoint( .5*(upperLeft.x + upperRight.x), - upperLeft.y, + upperLeft.y, std::isnan(upperLeft.value) ? upperRight.value : (std::isnan(upperRight.value) ? upperLeft.value : .5*(upperLeft.value + upperRight.value))); @@ -446,16 +447,16 @@ struct Square switch (border) { case LEFT_BORDER: - return Point(upperLeft.x, interpolate_(level, lowerLeft.y, upperLeft.y, + return Point(upperLeft.x, interpolate_(level, lowerLeft.y, upperLeft.y, lowerLeft.value, upperLeft.value, !split)); case LOWER_BORDER: - return Point(interpolate_(level, lowerLeft.x, lowerRight.x, + return Point(interpolate_(level, lowerLeft.x, lowerRight.x, lowerLeft.value, lowerRight.value, !split), lowerLeft.y); case RIGHT_BORDER: - return Point(upperRight.x, interpolate_(level, lowerRight.y, upperRight.y, + return Point(upperRight.x, interpolate_(level, lowerRight.y, upperRight.y, lowerRight.value, upperRight.value, !split)); case UPPER_BORDER: - return Point(interpolate_(level, upperLeft.x, upperRight.x, + return Point(interpolate_(level, upperLeft.x, upperRight.x, upperLeft.value, upperRight.value, !split), upperLeft.y); } assert(false); diff --git a/apps/gdalinfo_lib.cpp b/apps/gdalinfo_lib.cpp index 21ef658cf93f..f171c9b089af 100644 --- a/apps/gdalinfo_lib.cpp +++ b/apps/gdalinfo_lib.cpp @@ -33,6 +33,7 @@ #include "gdal_utils_priv.h" #include +#include #include #include #include diff --git a/autotest/cpp/test_cpl.cpp b/autotest/cpp/test_cpl.cpp index 00dc974b600b..31d4e8564ab0 100644 --- a/autotest/cpp/test_cpl.cpp +++ b/autotest/cpp/test_cpl.cpp @@ -57,6 +57,7 @@ #include "cpl_threadsafe_queue.hpp" #include +#include #include #include diff --git a/frmts/adrg/srpdataset.cpp b/frmts/adrg/srpdataset.cpp index beb60328fe06..868ee2840c30 100644 --- a/frmts/adrg/srpdataset.cpp +++ b/frmts/adrg/srpdataset.cpp @@ -35,6 +35,7 @@ #include #include +#include // Uncomment to recognize also .gen files in addition to .img files // #define OPEN_GEN diff --git a/frmts/basisu_ktx2/common.cpp b/frmts/basisu_ktx2/common.cpp index 59a883d6efc0..991da4299747 100644 --- a/frmts/basisu_ktx2/common.cpp +++ b/frmts/basisu_ktx2/common.cpp @@ -30,6 +30,7 @@ #include "common.h" #include "include_basisu_sdk.h" +#include #include /************************************************************************/ diff --git a/frmts/exr/exrdataset.cpp b/frmts/exr/exrdataset.cpp index ed310935f8ee..406c8fbaaa46 100644 --- a/frmts/exr/exrdataset.cpp +++ b/frmts/exr/exrdataset.cpp @@ -29,6 +29,7 @@ #include "ogr_spatialref.h" #include +#include #include #include "openexr_headers.h" diff --git a/frmts/fit/fitdataset.cpp b/frmts/fit/fitdataset.cpp index 1d43d7f2ac94..5bee53bfbd4f 100644 --- a/frmts/fit/fitdataset.cpp +++ b/frmts/fit/fitdataset.cpp @@ -35,7 +35,7 @@ #include "cpl_safemaths.hpp" #include - +#include constexpr size_t FIT_PAGE_SIZE = 128; diff --git a/frmts/grib/gribcreatecopy.cpp b/frmts/grib/gribcreatecopy.cpp index 694085698ae3..fa50b5a26418 100644 --- a/frmts/grib/gribcreatecopy.cpp +++ b/frmts/grib/gribcreatecopy.cpp @@ -36,6 +36,7 @@ #include "gdal_priv_templates.hpp" #include "memdataset.h" +#include #include #include "degrib/degrib/meta.h" diff --git a/frmts/gtiff/geotiff.cpp b/frmts/gtiff/geotiff.cpp index 9b41f8f45933..7420efbd3172 100644 --- a/frmts/gtiff/geotiff.cpp +++ b/frmts/gtiff/geotiff.cpp @@ -48,6 +48,7 @@ #endif #include +#include #include #include #include diff --git a/frmts/hfa/hfadataset.cpp b/frmts/hfa/hfadataset.cpp index 366095a8e058..beb47c983ad8 100644 --- a/frmts/hfa/hfadataset.cpp +++ b/frmts/hfa/hfadataset.cpp @@ -43,6 +43,7 @@ # include #endif #include +#include #include #include #include diff --git a/frmts/jpeg/jpgdataset.cpp b/frmts/jpeg/jpgdataset.cpp index 2836cc099ad3..d7489f3fdde5 100644 --- a/frmts/jpeg/jpgdataset.cpp +++ b/frmts/jpeg/jpgdataset.cpp @@ -43,6 +43,7 @@ #if HAVE_FCNTL_H # include #endif +#include #include #include diff --git a/frmts/pdf/pdfcreatefromcomposition.cpp b/frmts/pdf/pdfcreatefromcomposition.cpp index fa2ca38f10f4..7bc75a59c5f2 100644 --- a/frmts/pdf/pdfcreatefromcomposition.cpp +++ b/frmts/pdf/pdfcreatefromcomposition.cpp @@ -30,6 +30,7 @@ #include "gdal_pdf.h" #include "pdfcreatecopy.h" +#include #include #include diff --git a/frmts/raw/byndataset.cpp b/frmts/raw/byndataset.cpp index f067ae4e4ecd..19b389dd8d10 100644 --- a/frmts/raw/byndataset.cpp +++ b/frmts/raw/byndataset.cpp @@ -37,7 +37,7 @@ #include "ogr_srs_api.h" #include - +#include // Specification at // https://www.nrcan.gc.ca/sites/www.nrcan.gc.ca/files/earthsciences/pdf/gpshgrid_e.pdf diff --git a/frmts/rdb/rdbdataset.cpp b/frmts/rdb/rdbdataset.cpp index f92e5820194b..bd64827ff7d6 100644 --- a/frmts/rdb/rdbdataset.cpp +++ b/frmts/rdb/rdbdataset.cpp @@ -31,6 +31,8 @@ #include "rdbdataset.hpp" +#include +#include #include #include diff --git a/frmts/rdb/rdbdataset.hpp b/frmts/rdb/rdbdataset.hpp index 8b5eb491eaf5..750c7c53500f 100644 --- a/frmts/rdb/rdbdataset.hpp +++ b/frmts/rdb/rdbdataset.hpp @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -147,4 +148,4 @@ class RDBRasterBand CPL_NON_FINAL: public GDALPamRasterBand } // namespace rdb void GDALRegister_RDB(); -#endif // RDB_DATASET_INCLUDED \ No newline at end of file +#endif // RDB_DATASET_INCLUDED diff --git a/frmts/rmf/rmfdataset.cpp b/frmts/rmf/rmfdataset.cpp index c987eced406c..37b83752d65c 100644 --- a/frmts/rmf/rmfdataset.cpp +++ b/frmts/rmf/rmfdataset.cpp @@ -27,6 +27,7 @@ * DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include +#include #include "cpl_string.h" #include "gdal_frmts.h" diff --git a/frmts/rmf/rmfdem.cpp b/frmts/rmf/rmfdem.cpp index 36df4619e380..09d75a8d57b9 100644 --- a/frmts/rmf/rmfdem.cpp +++ b/frmts/rmf/rmfdem.cpp @@ -31,6 +31,7 @@ #include "rmfdataset.h" +#include /* * The encoded data stream is a series of records. diff --git a/frmts/sigdem/sigdemdataset.cpp b/frmts/sigdem/sigdemdataset.cpp index 30260cff84e1..3e497014ae99 100644 --- a/frmts/sigdem/sigdemdataset.cpp +++ b/frmts/sigdem/sigdemdataset.cpp @@ -30,7 +30,7 @@ #include "rawdataset.h" #include - +#include #ifdef CPL_IS_LSB #define SWAP_SIGDEM_HEADER(abyHeader) { \ diff --git a/frmts/wms/gdalwmsrasterband.cpp b/frmts/wms/gdalwmsrasterband.cpp index e327bf5b29d1..9add44756b59 100644 --- a/frmts/wms/gdalwmsrasterband.cpp +++ b/frmts/wms/gdalwmsrasterband.cpp @@ -31,6 +31,7 @@ #include "wmsdriver.h" +#include GDALWMSRasterBand::GDALWMSRasterBand(GDALWMSDataset *parent_dataset, int band, double scale): diff --git a/gcore/gdalmultidim.cpp b/gcore/gdalmultidim.cpp index 8afe8a65a043..943ddd50c4c6 100644 --- a/gcore/gdalmultidim.cpp +++ b/gcore/gdalmultidim.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include diff --git a/gcore/tilematrixset.cpp b/gcore/tilematrixset.cpp index b99836d64e5c..92e1dfc70c57 100644 --- a/gcore/tilematrixset.cpp +++ b/gcore/tilematrixset.cpp @@ -31,6 +31,7 @@ #include #include +#include #include "tilematrixset.hpp" diff --git a/ogr/ogrcircularstring.cpp b/ogr/ogrcircularstring.cpp index 4768b48b463d..72f3047d4b70 100644 --- a/ogr/ogrcircularstring.cpp +++ b/ogr/ogrcircularstring.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include "cpl_error.h" diff --git a/ogr/ogrlinearring.cpp b/ogr/ogrlinearring.cpp index da961790ad9e..774f433cb782 100644 --- a/ogr/ogrlinearring.cpp +++ b/ogr/ogrlinearring.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include "cpl_error.h" #include "ogr_core.h" diff --git a/ogr/ogrsf_frmts/arrow_common/ograrrowlayer.hpp b/ogr/ogrsf_frmts/arrow_common/ograrrowlayer.hpp index d95284967bf5..6bcbf4e08abf 100644 --- a/ogr/ogrsf_frmts/arrow_common/ograrrowlayer.hpp +++ b/ogr/ogrsf_frmts/arrow_common/ograrrowlayer.hpp @@ -33,7 +33,9 @@ #include "ogr_p.h" #include "ogr_swq.h" +#include #include +#include #define SWQ_ISNOTNULL (-SWQ_ISNULL) diff --git a/ogr/ogrsf_frmts/arrow_common/ograrrowwriterlayer.hpp b/ogr/ogrsf_frmts/arrow_common/ograrrowwriterlayer.hpp index b71c3e717779..02aff0e3f178 100644 --- a/ogr/ogrsf_frmts/arrow_common/ograrrowwriterlayer.hpp +++ b/ogr/ogrsf_frmts/arrow_common/ograrrowwriterlayer.hpp @@ -33,6 +33,7 @@ #include "cpl_time.h" #include +#include static constexpr int TZFLAG_UNINITIALIZED = -1; static constexpr int TZFLAG_MIXED = -2; diff --git a/ogr/ogrsf_frmts/cad/ogrcadlayer.cpp b/ogr/ogrsf_frmts/cad/ogrcadlayer.cpp index 48230afa1364..80c1f1a730a5 100644 --- a/ogr/ogrsf_frmts/cad/ogrcadlayer.cpp +++ b/ogr/ogrsf_frmts/cad/ogrcadlayer.cpp @@ -31,6 +31,7 @@ #include "cpl_conv.h" #include "ogr_cad.h" +#include #include #include diff --git a/ogr/ogrsf_frmts/elastic/ogrelasticaggregationlayer.cpp b/ogr/ogrsf_frmts/elastic/ogrelasticaggregationlayer.cpp index 460a55e0561f..4a97ec0f022f 100644 --- a/ogr/ogrsf_frmts/elastic/ogrelasticaggregationlayer.cpp +++ b/ogr/ogrsf_frmts/elastic/ogrelasticaggregationlayer.cpp @@ -30,6 +30,7 @@ #include "ogrgeojsonreader.h" #include "cpl_json.h" +#include #include diff --git a/ogr/ogrsf_frmts/flatgeobuf/packedrtree.cpp b/ogr/ogrsf_frmts/flatgeobuf/packedrtree.cpp index 39b731f679a8..57f7530a0098 100644 --- a/ogr/ogrsf_frmts/flatgeobuf/packedrtree.cpp +++ b/ogr/ogrsf_frmts/flatgeobuf/packedrtree.cpp @@ -36,6 +36,8 @@ #include "packedrtree.h" +#include +#include #include #include #include diff --git a/ogr/ogrsf_frmts/generic/ograrrowarrayhelper.cpp b/ogr/ogrsf_frmts/generic/ograrrowarrayhelper.cpp index b11341bb3757..c065896e434d 100644 --- a/ogr/ogrsf_frmts/generic/ograrrowarrayhelper.cpp +++ b/ogr/ogrsf_frmts/generic/ograrrowarrayhelper.cpp @@ -28,6 +28,8 @@ #include "ograrrowarrayhelper.h" +#include + //! @cond Doxygen_Suppress /************************************************************************/ diff --git a/ogr/ogrsf_frmts/generic/ograrrowarrayhelper.h b/ogr/ogrsf_frmts/generic/ograrrowarrayhelper.h index 1d59806d9a18..4df4a10f9b84 100644 --- a/ogr/ogrsf_frmts/generic/ograrrowarrayhelper.h +++ b/ogr/ogrsf_frmts/generic/ograrrowarrayhelper.h @@ -31,6 +31,7 @@ //! @cond Doxygen_Suppress #include +#include #include "cpl_time.h" diff --git a/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp b/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp index afebafd208f5..3cba666ea458 100644 --- a/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp +++ b/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp @@ -41,6 +41,7 @@ #include "cpl_json_streaming_parser.h" #include "ogr_api.h" +#include static OGRGeometry* OGRGeoJSONReadGeometry( json_object* poObj, diff --git a/ogr/ogrsf_frmts/gpkg/ogrgeopackagetablelayer.cpp b/ogr/ogrsf_frmts/gpkg/ogrgeopackagetablelayer.cpp index 87027dc5adb2..432a7fd5eb65 100644 --- a/ogr/ogrsf_frmts/gpkg/ogrgeopackagetablelayer.cpp +++ b/ogr/ogrsf_frmts/gpkg/ogrgeopackagetablelayer.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #undef SQLITE_STATIC #define SQLITE_STATIC static_cast(nullptr) diff --git a/ogr/ogrsf_frmts/hana/ogrhanafeaturereader.cpp b/ogr/ogrsf_frmts/hana/ogrhanafeaturereader.cpp index 92fa18cc4bf3..f936a003c37b 100644 --- a/ogr/ogrsf_frmts/hana/ogrhanafeaturereader.cpp +++ b/ogr/ogrsf_frmts/hana/ogrhanafeaturereader.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include "odbc/Types.h" diff --git a/ogr/ogrsf_frmts/hana/ogrhanatablelayer.cpp b/ogr/ogrsf_frmts/hana/ogrhanatablelayer.cpp index 4165fa0397dd..e6d162fcbd39 100644 --- a/ogr/ogrsf_frmts/hana/ogrhanatablelayer.cpp +++ b/ogr/ogrsf_frmts/hana/ogrhanatablelayer.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include "odbc/Exception.h" diff --git a/ogr/ogrsf_frmts/ngw/gdalngwdataset.cpp b/ogr/ogrsf_frmts/ngw/gdalngwdataset.cpp index 2a9b95cced11..6ec2e329563d 100644 --- a/ogr/ogrsf_frmts/ngw/gdalngwdataset.cpp +++ b/ogr/ogrsf_frmts/ngw/gdalngwdataset.cpp @@ -32,6 +32,8 @@ #include "cpl_http.h" #include "gdal_proxy.h" +#include + class NGWWrapperRasterBand : public GDALProxyRasterBand { GDALRasterBand *poBaseBand; diff --git a/ogr/ogrsf_frmts/ngw/ngw_api.cpp b/ogr/ogrsf_frmts/ngw/ngw_api.cpp index 056fdc994466..0ec8b42a9abc 100644 --- a/ogr/ogrsf_frmts/ngw/ngw_api.cpp +++ b/ogr/ogrsf_frmts/ngw/ngw_api.cpp @@ -31,6 +31,8 @@ #include "cpl_http.h" +#include + namespace NGWAPI { std::string GetPermissions(const std::string &osUrl, const std::string &osResourceId) diff --git a/ogr/ogrsf_frmts/openfilegdb/filegdbtable_priv.h b/ogr/ogrsf_frmts/openfilegdb/filegdbtable_priv.h index e60925828f7e..4ad9ab31b996 100644 --- a/ogr/ogrsf_frmts/openfilegdb/filegdbtable_priv.h +++ b/ogr/ogrsf_frmts/openfilegdb/filegdbtable_priv.h @@ -37,6 +37,7 @@ #include #include #include +#include #define DIV_ROUND_UP(a, b) ( ((a) % (b)) == 0 ? ((a) / (b)) : (((a) / (b)) + 1) ) diff --git a/ogr/ogrsf_frmts/parquet/ogrparquetdatasetlayer.cpp b/ogr/ogrsf_frmts/parquet/ogrparquetdatasetlayer.cpp index f4362a6308df..58e41c50f038 100644 --- a/ogr/ogrsf_frmts/parquet/ogrparquetdatasetlayer.cpp +++ b/ogr/ogrsf_frmts/parquet/ogrparquetdatasetlayer.cpp @@ -28,6 +28,7 @@ #include "ogrsf_frmts.h" +#include #include #include #include diff --git a/ogr/ogrsf_frmts/sqlite/ogrsqlitelayer.cpp b/ogr/ogrsf_frmts/sqlite/ogrsqlitelayer.cpp index f305b7d12a3c..23714cbfa3b8 100644 --- a/ogr/ogrsf_frmts/sqlite/ogrsqlitelayer.cpp +++ b/ogr/ogrsf_frmts/sqlite/ogrsqlitelayer.cpp @@ -40,6 +40,7 @@ #include "ogr_sqlite.h" #include "ogrsqliteutility.h" +#include #include #include #include diff --git a/port/cpl_compressor.cpp b/port/cpl_compressor.cpp index 5eb692aaffb7..6be028c841da 100644 --- a/port/cpl_compressor.cpp +++ b/port/cpl_compressor.cpp @@ -60,6 +60,7 @@ #include #endif +#include #include #include #include diff --git a/port/cpl_odbc.cpp b/port/cpl_odbc.cpp index abadee43cbd8..782e417faa4c 100644 --- a/port/cpl_odbc.cpp +++ b/port/cpl_odbc.cpp @@ -34,6 +34,7 @@ #include "cpl_string.h" #include "cpl_error.h" +#include #include diff --git a/port/cpl_vsil_cache.cpp b/port/cpl_vsil_cache.cpp index bed6f7362c60..798329eebe73 100644 --- a/port/cpl_vsil_cache.cpp +++ b/port/cpl_vsil_cache.cpp @@ -37,6 +37,7 @@ #endif #include +#include #include #include #include diff --git a/port/cpl_vsil_curl_class.h b/port/cpl_vsil_curl_class.h index ee82f6ba21da..57764b3fd151 100644 --- a/port/cpl_vsil_curl_class.h +++ b/port/cpl_vsil_curl_class.h @@ -41,6 +41,7 @@ #include "cpl_curl_priv.h" +#include #include #include #include diff --git a/port/cpl_vsisimple.cpp b/port/cpl_vsisimple.cpp index 491e74efb2e1..a90ad5b8b73d 100644 --- a/port/cpl_vsisimple.cpp +++ b/port/cpl_vsisimple.cpp @@ -37,6 +37,7 @@ #include "cpl_port.h" #include "cpl_vsi.h" +#include #include #include #include diff --git a/scripts/detect_missing_include.sh b/scripts/detect_missing_include.sh new file mode 100755 index 000000000000..73b580f0adc8 --- /dev/null +++ b/scripts/detect_missing_include.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +set -eu + +SCRIPT_DIR=$(dirname "$0") +case $SCRIPT_DIR in + "/"*) + ;; + ".") + SCRIPT_DIR=$(pwd) + ;; + *) + SCRIPT_DIR=$(pwd)/$(dirname "$0") + ;; +esac +GDAL_ROOT=$SCRIPT_DIR/.. +cd "$GDAL_ROOT" + +ret_code=0 + +find alg port gcore apps ogr frmts gnm autotest/cpp \( -name "*.cpp" -o -name "*.h" -o -name "*.hpp" \) > /tmp/gdal_list_files.txt + +echo "Checking for missing #include statements..." +rm -f /tmp/missing_include.txt +while read -r i; do + grep -e std::min -e std::max $i >/dev/null && (grep "#include " $i >/dev/null || echo $i) | grep -v ogr/ogrsf_frmts/flatgeobuf/flatbuffers/ | tee -a /tmp/missing_include.txt; +done < /tmp/gdal_list_files.txt + +if test -s /tmp/missing_include.txt; then + echo "FAIL: missing #include in above listed files" + ret_code=1 +else + echo "OK." +fi + + +echo "Checking for missing #include statements..." +rm -f /tmp/missing_include.txt +while read -r i; do + grep -e std::numeric_limits $i >/dev/null && (grep "#include " $i >/dev/null || echo $i) | grep -v ogr/ogrsf_frmts/flatgeobuf/flatbuffers/ | tee -a /tmp/missing_include.txt; +done < /tmp/gdal_list_files.txt + + +if test -s /tmp/missing_include.txt; then + echo "FAIL: missing #include in above listed files" + ret_code=1 +else + echo "OK." +fi + +rm -f /tmp/missing_include.txt +rm -f /tmp/gdal_list_files.txt + +exit $ret_code