Workaround MSVC STL deficiency in C++17 mode

Compiling jet_test using the /std:c++17 switch triggers a C3198 compile
error in <numeric>. Moving #pragma below all the includes, allows to
workaround the issue.

Additionally, locally ensure the floating-point model is always
/fp:precise to be able to access the floating-point environment in
jet_test.

Change-Id: Ia5b3a3dac13baf46546ac1d0d304fc05512f8816
This commit is contained in:
Sergiu Deitsch
2022-03-20 12:12:51 +01:00
committed by Sameer Agarwal
parent 97c232857d
commit ab9436cb9e
+16 -11
View File
@@ -28,17 +28,6 @@
//
// Author: keir@google.com (Keir Mierle)
// The floating-point environment access and modification is only meaningful
// with the following pragma.
#ifdef _MSC_VER
#pragma fenv_access(on)
#elif !(defined(__ARM_ARCH) && __ARM_ARCH >= 8)
// NOTE: FENV_ACCESS cannot be set to ON when targeting arm(v8)
#pragma STDC FENV_ACCESS ON
#else
#define CERES_NO_FENV_ACCESS
#endif
#include "ceres/jet.h"
#include <Eigen/Dense>
@@ -52,6 +41,18 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
// The floating-point environment access and modification is only meaningful
// with the following pragma.
#ifdef _MSC_VER
#pragma float_control(precise, on, push)
#pragma fenv_access(on)
#elif !(defined(__ARM_ARCH) && __ARM_ARCH >= 8)
// NOTE: FENV_ACCESS cannot be set to ON when targeting arm(v8)
#pragma STDC FENV_ACCESS ON
#else
#define CERES_NO_FENV_ACCESS
#endif
namespace ceres {
namespace internal {
@@ -1293,3 +1294,7 @@ TYPED_TEST(JetTest, Nested3XComparison) {
} // namespace internal
} // namespace ceres
#ifdef _MSC_VER
#pragma float_control(pop)
#endif