changeset 6580:e16d84c4d0e5

fix compatibility with Win32
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 27 Jan 2026 17:19:25 +0100
parents dd7b19b63d56
children fa7123b2930a
files OrthancFramework/Sources/CompatibilityMath.h
diffstat 1 files changed, 19 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/CompatibilityMath.h	Tue Jan 27 16:55:17 2026 +0100
+++ b/OrthancFramework/Sources/CompatibilityMath.h	Tue Jan 27 17:19:25 2026 +0100
@@ -96,24 +96,31 @@
       bool RoundFloatWithChecks(T& target,
                                 float source)
       {
+#if defined(_WIN64)
+        // The functions "_isnanf()" and "_finitef()" are only available if targeting x64
         if (_isnanf(source) ||
             !_finitef(source))
         {
           return false;
         }
+#else
+        if (_isnan(static_cast<double>(source)) ||
+            !_finite(static_cast<double>(source)))
+        {
+          return false;
+        }
+#endif
+
+        const float rounded = RoundFloat(source);
+        if (rounded < static_cast<float>(std::numeric_limits<T>::min()) ||
+            rounded > static_cast<float>(std::numeric_limits<T>::max()))
+        {
+          return false;
+        }
         else
         {
-          float rounded = RoundFloat(source);
-          if (rounded < static_cast<float>(std::numeric_limits<T>::min()) ||
-              rounded > static_cast<float>(std::numeric_limits<T>::max()))
-          {
-            return false;
-          }
-          else
-          {
-            target = static_cast<T>(rounded);
-            return true;
-          }
+          target = static_cast<T>(rounded);
+          return true;
         }
       }
 
@@ -129,7 +136,7 @@
         }
         else
         {
-          double rounded = RoundDouble(source);
+          const double rounded = RoundDouble(source);
           if (rounded < static_cast<double>(std::numeric_limits<T>::min()) ||
               rounded > static_cast<double>(std::numeric_limits<T>::max()))
           {