VCityTeam / TunNetGen

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PureCpp fails to compile on OSX 12.1

EricBoix opened this issue · comments

On platform

  • OSX 12.1
  • cmake version 3.25.1
  • GNU Make 3.81
  • Apple clang version 13.0.0 (clang-1300.0.29.30)
    Target: x86_64-apple-darwin21.2.0

PureCpp fails to build (mkdir build && cd build && cmake .. && make with messages

[...]/TunNetGen/PureCPP/src/vec.ipp:111:12: error: out-of-line definition of 'norm' does not match any declaration in namespace 'gbl'
float gbl::norm(const gbl::Vec<N, float>& v)
           ^~~~
[...]/TunNetGen/PureCPP/src/lidar.cpp:8:14: error: no member named 'numbers' in namespace 'std'
  using std::numbers::pi;
        ~~~~~^
[...]/TunNetGen/PureCPP/src/lidar.cpp:9:18: error: use of undeclared identifier 'pi'
  float dphi = 2*pi/(Nphi-1);
                 ^
[...]

Error message on glb::norm seems to be fixed by this commit.

Indeed the message concerning glb::norm doesn't appear anymore.

Yet the error on std::number::pi persists although:

  • CMakeLists.txt requires c++ standard 20 (refer to set(CMAKE_CXX_STANDARD 20) and set(CMAKE_CXX_STANDARD_REQUIRED True))
  • C++ standard 20 indeed defines pi
    the proper required inclusions seems to be #include <numbers>.

It also seems that in C++-20 the min and max template functions require #include <algorithm>.

I proposed the std_lib_fixes branch with those changes.
They do fix the issue on OSX with both Apple Clang 13.0.0 and Homebrew clang version 17.0.6.
That branch also builds with the docker context provided in this repo (docker/PureCPP/Dockerfile) that uses g++ 11.2.1 (alpine:3.16) .

Could you please assert these changes on your platform ?

It looks ok for me