diff --git a/include/soci/soci-platform.h b/include/soci/soci-platform.h index 125f772fe..cd0a21596 100644 --- a/include/soci/soci-platform.h +++ b/include/soci/soci-platform.h @@ -37,10 +37,6 @@ //base class must have dll interface #pragma warning(disable:4251 4275) -// As long as we don't require C++17, we must disable the warning -// "conditional expression is constant" -#pragma warning(disable:4127) - // Define if you have the vsnprintf variants. #if _MSC_VER < 1500 # define vsnprintf _vsnprintf diff --git a/include/soci/type-holder.h b/include/soci/type-holder.h index 7b366c302..121e11227 100644 --- a/include/soci/type-holder.h +++ b/include/soci/type-holder.h @@ -10,7 +10,6 @@ #include "soci/error.h" #include "soci/soci-backend.h" -#include "soci/soci-platform.h" #include "soci/soci-types.h" #include @@ -89,11 +88,20 @@ struct soci_cast< uintmax_t t_max = static_cast((std::numeric_limits::max)()); uintmax_t u_max = static_cast((std::numeric_limits::max)()); +#ifdef _MSC_VER +// As long as we don't require C++17, we must disable the warning +// "conditional expression is constant" as it can give false positives here. +#pragma warning(push) +#pragma warning(disable:4127) +#endif if ((t_min > u_min && val < static_cast(t_min)) || (t_max < u_max && val > static_cast(t_max))) { throw std::bad_cast(); } +#ifdef _MSC_VER +#pragma warning(pop) +#endif return static_cast(val); }