Only use collapse() directive with OpenMP 3.0 or higher Change-Id: Icba544c0494763c57eb6dc61e98379312ca15972
diff --git a/internal/ceres/covariance_impl.cc b/internal/ceres/covariance_impl.cc index 8c083fa..0fa40ce 100644 --- a/internal/ceres/covariance_impl.cc +++ b/internal/ceres/covariance_impl.cc
@@ -337,7 +337,14 @@ max_covariance_block_size]); bool success = true; -#pragma omp parallel for num_threads(num_threads) schedule(dynamic) collapse(2) + +// The collapse() directive is only supported in OpenMP 3.0 and higher. OpenMP +// 3.0 was released in May 2008 (hence the version number). +#if _OPENMP >= 200805 +# pragma omp parallel for num_threads(num_threads) schedule(dynamic) collapse(2) +#else +# pragma omp parallel for num_threads(num_threads) schedule(dynamic) +#endif for (int i = 0; i < parameters.size(); ++i) { for (int j = 0; j < parameters.size(); ++j) { // The second loop can't start from j = i for compatibility with OpenMP