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
diff --git a/internal/ceres/jet_test.cc b/internal/ceres/jet_test.cc index 44db7aa..6f71b77 100644 --- a/internal/ceres/jet_test.cc +++ b/internal/ceres/jet_test.cc
@@ -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 @@ } // namespace internal } // namespace ceres + +#ifdef _MSC_VER +#pragma float_control(pop) +#endif