pelicanmapping / rocky

3D Geospatial SDK (C++17 / Vulkan / VSG)
MIT License
91 stars 15 forks source link

clang (XCode 14) compile errors #7

Closed remoe closed 1 year ago

remoe commented 1 year ago

1

Error: "Incomplete type 'rocky::util::job_scheduler' named in nested name specifier" at job_scheduler::Delegate delegate = [task, promise]() mutable ... https://github.com/pelicanmapping/rocky/blob/main/src/rocky/Threading.h#L488

because

https://github.com/pelicanmapping/rocky/blob/main/src/rocky/Threading.h#L572

"using Delegate" is not forward declared and can't be forward declared:

https://github.com/pelicanmapping/rocky/blob/main/src/rocky/Threading.h#L397

2

Error: Use of undeclared identifier 'options'

 template<typename T>
 T Layer::userProperty(const std::string& key, T fallback) const {
    return options()._internal().value(key, fallback);
 }

3

rocky/srs.h

static const SRS WGS84; Error: duplicated member WGS84

need to delete:

        static const SRS WGS84;
        static const SRS ECEF;
        static const SRS SPHERICAL_MERCATOR;
        static const SRS PLATE_CARREE;
        static const SRS EMPTY;

SRS& SRS::operator=(SRS&&);

Error: extra qualification on member 'operator='

need to change:

`SRS& operator=(SRS&&);``

4

rocky/Heightfield.h

     template<typename FUNC>
     void Heightfield::forEachHeight(FUNC func) const
     {
-        float* ptr = data<float>();
+        const float* ptr = data<float>();
         for (auto i = 0u; i < sizeInPixels(); ++i, ++ptr)
             func(*ptr);
     }

5

rocky/Image.h

     template<typename UV_TYPE, typename ST_TYPE>
     void Image::nnUVtoST(UV_TYPE u, UV_TYPE v, ST_TYPE& s, ST_TYPE& t)
     {
-        const UV_TYPE umin = 1.0 / (2.0 * width);
-        const UV_TYPE vmin = 1.0 / (2.0 * height);
-        s = u<umin ? 0 : u>(1.0 - umin) ? width - 1 : (int)floor(u*(double)width);
-        t = v<vmin ? 0 : v>(1.0 - vmin) ? height - 1 : (int)floor(v*(double)height);
+        const UV_TYPE umin = 1.0 / (2.0 * width());
+        const UV_TYPE vmin = 1.0 / (2.0 * height());
+        s = u<umin ? 0 : u>(1.0 - umin) ? width() - 1 : (int)floor(u*(double)width());
+        t = v<vmin ? 0 : v>(1.0 - vmin) ? height() - 1 : (int)floor(v*(double)height());

     }

6

rocky/IOTypes.h

        bool fromCache = false;
        JSON metadata;

-       template<typename T>
        IOResult(const T& result) :
            Result<T>(result) { }

For this I can't do a PR. I will try to compile it further after the issues are fixed ...

gwaldron commented 1 year ago

Thanks Remo! All are fixed.

remoe commented 1 year ago

I've tried it with the following CMake config:

-DROCKY_SUPPORTS_MBTILES=OFF
-DROCKY_SUPPORTS_GDAL=OFF

Compile errors:

1

In file included from /src/rocky/src/rocky/TerrainTileModelFactory.cpp:7:
In file included from /src/rocky/src/rocky/Map.h:15:
/src/rocky/src/rocky/LayerCollection.h:88:35: error: member access into incomplete type 'rocky::Map'
        std::shared_lock lock(_map->_mapDataMutex);
                                  ^
In file included from /src/rocky/src/rocky/TerrainTileModelFactory.cpp:6:
In file included from /src/rocky/src/rocky/TerrainTileModelFactory.h:8:
/src/rocky/src/rocky/TerrainTileModel.h:20:11: note: forward declaration of 'rocky::Map'
    class Map;
          ^
In file included from /src/rocky/src/rocky/TerrainTileModelFactory.cpp:7:
In file included from /src/rocky/src/rocky/Map.h:15:
/src/rocky/src/rocky/LayerCollection.h:98:35: error: member access into incomplete type 'rocky::Map'
        std::shared_lock lock(_map->_mapDataMutex);
                                  ^
In file included from /src/rocky/src/rocky/TerrainTileModelFactory.cpp:6:
In file included from /src/rocky/src/rocky/TerrainTileModelFactory.h:8:
/src/rocky/src/rocky/TerrainTileModel.h:20:11: note: forward declaration of 'rocky::Map'
    class Map;
          ^
In file included from /src/rocky/src/rocky/TerrainTileModelFactory.cpp:7:
In file included from /src/rocky/src/rocky/Map.h:15:
/src/rocky/src/rocky/LayerCollection.h:108:35: error: member access into incomplete type 'rocky::Map'
        std::shared_lock lock(_map->_mapDataMutex);
                                  ^
In file included from /src/rocky/src/rocky/TerrainTileModelFactory.cpp:6:
In file included from /src/rocky/src/rocky/TerrainTileModelFactory.h:8:
/src/rocky/src/rocky/TerrainTileModel.h:20:11: note: forward declaration of 'rocky::Map'
    class Map;
          ^
3 errors generated.

The code has compile issues in LayerCollection.h. The forward declare of Map:

https://github.com/pelicanmapping/rocky/blob/main/src/rocky/LayerCollection.h#L13

can't work with the following template implementation:

https://github.com/pelicanmapping/rocky/blob/main/src/rocky/LayerCollection.h#L88

And it doesn't compile with #include <rocky/Map.h> .

2

rocky/src/rocky/TMS.cpp:758:25: error: no matching function for call to object of type 'const rocky::ReadImageStreamService' (aka 'const function<Result<shared_ptr<rocky::Image>> (basic_istream<char> &, basic_string<char, char_traits<char>, allocator<char>>, const rocky::IOOptions &)>')
        auto image_rr = io.services().readImageFromStream(
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from rocky/src/rocky/TMS.cpp:6:
In file included from rocky/src/rocky/TMS.h:8:
In file included from rocky/src/rocky/URI.h:8:
In file included from rocky/src/rocky/Common.h:34:

/usr/include/c++/v1/__functional/function.h:1059:9: note: candidate function not viable: expects an lvalue for 1st argument
    _Rp operator()(_ArgTypes...) const;
        ^
1 error generated.

3

rocky/src/rocky/URI.cpp:21:22: error: use of undeclared identifier 'OPENSSL_VERSION_STR'
ROCKY_ABOUT(openssl, OPENSSL_VERSION_STR)
remoe commented 1 year ago

The joband job_scheduler class must be separated, because of circular dependencies? Or should at least the job::dispatch implementation be moved to Threading.cpp?

gwaldron commented 1 year ago

Remo, I feel like many of these issues are just templates being instantiated before they are used. Is there some king of clang option for this? Because it isn't a problem on MSVC. Don't know about GCC.

I made another push to (hopefully) address these latest ones.

remoe commented 1 year ago

I haven't found a clang option to configure template instancing. Currently, I'm able to compile the project with my additional PR. But it need more work to link and run it.