isciences / exactextract

Fast and accurate raster zonal statistics
Apache License 2.0
258 stars 33 forks source link

Compilation error traced to `set` function override in `gdal_feature` #113

Closed mgcooper closed 4 months ago

mgcooper commented 4 months ago

When attempting to compile the code, I got an error:

gdal_feature.h:135:58: error: only virtual member functions can be marked 'override'
# Or in vscode:
# member function declared with 'override' does not override a base class member

The signature in gdal_feature is:

void set(const std::string& name, std::size_t value) override;

I noticed there is no matching virtual function in feature.h i.e. Feature does not declare something like:

virtual void set(const std::string& name, std::size_t value) = 0;

or anything like that. So I removed the override specifier and it compiled (but the related tests failed, see next PR).

Steps to Reproduce:

  1. Compile the code.
    cmake -DBUILD_PYTHON:=OFF -DCMAKE_BUILD_TYPE=Release ..
    make
  2. Get the error related to the override keyword.
  3. Alternatively, open gdal_feature.h and check line 135.

Expected Behavior: The code compiles without errors.

Proposed Solution: Remove the override specifier from the set function in the derived class GDALFeature.

More info

cmake step:

…/exactextract/build on  master via 🐍 v3.9.0 (tools3) with /usr/local/bin/bash
❯ cmake -DBUILD_PYTHON:=OFF -DCMAKE_INSTALL_PREFIX=/Users/coop558/opt/local -DCMAKE_BUILD_TYPE=Release ..
-- The C compiler identification is AppleClang 15.0.0.15000309
-- The CXX compiler identification is AppleClang 15.0.0.15000309
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- GEOS version: 3.12.1
-- Source version: 0.2.0-dev (79ea9dd)
-- Found GDAL: /usr/local/Cellar/gdal/3.9.0/lib/libgdal.dylib (found version "3.9.0")
# ... this all went fine so truncating here

make:

…/exactextract/build on  master via △ v3.29.3 via 🐍 v3.9.0 (tools3) with /usr/local/bin/bash
❯ make
[  2%] Building CXX object CMakeFiles/exactextract_gdal.dir/src/deferred_gdal_writer.cpp.o
In file included from /Users/coop558/opt/exactextract/src/deferred_gdal_writer.cpp:15:
/Users/coop558/opt/exactextract/src/gdal_feature.h:135:58: error: only virtual member functions can be marked 'override'
    void set(const std::string& name, std::size_t value) override
                                                         ^~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/exactextract_gdal.dir/src/deferred_gdal_writer.cpp.o] Error 1
make[1]: *** [CMakeFiles/exactextract_gdal.dir/all] Error 2
make: *** [all] Error 2