Fix vector operations benchmark compilation Some of the benchmark functions use the same name as other functions in the ceres namespace. For example Axpby defines both benchmark but also an utility function in eigen_vector_ops.h. It seems to confuse some compilers and leads to a compilation error rooting deeper into the benchmark header itself: it seems that the compiler can not deduct which of the instances of such functions to use. Wrapping the file into an anonymous namespace solves the problem. Alternative could be to use benchmark namespace to make thins more explicit, for example ceres::internal::benchmark. Tested on the following configuration: - macOS 15.4 - Xcode 16.3 - Apple M3 CPU - google-benchmark 1.9.2 installed via homebrew Change-Id: Id127015dd22de99c6c3da88e71f255736e0bed82
diff --git a/internal/ceres/parallel_vector_operations_benchmark.cc b/internal/ceres/parallel_vector_operations_benchmark.cc index b658ea5..c3dcdb4 100644 --- a/internal/ceres/parallel_vector_operations_benchmark.cc +++ b/internal/ceres/parallel_vector_operations_benchmark.cc
@@ -34,6 +34,10 @@ #include "ceres/parallel_for.h" namespace ceres::internal { +// Wrap everything into an anonymous namespace to guide deduction of possibly +// polymorphic functions that define benchmark and which could be defined in the +// ceres namespace. +namespace { // Older versions of benchmark library (for example, one shipped with // ubuntu 20.04) do not support range generation and range products #define VECTOR_SIZES(num_threads) \ @@ -321,7 +325,7 @@ CHECK_GT(z.squaredNorm(), 0.); } BENCHMARK(AxpbyParallel)->VECTOR_SIZE_THREADS; - +} // namespace } // namespace ceres::internal BENCHMARK_MAIN();