diff OrthancFramework/Sources/Toolbox.cpp @ 5806:16df20505710 default

fix build for boost 1.86
author Alain Mazy <am@orthanc.team>
date Tue, 24 Sep 2024 09:26:42 +0200
parents e4d9a872998f
children
line wrap: on
line diff
--- a/OrthancFramework/Sources/Toolbox.cpp	Fri Sep 20 16:05:04 2024 +0200
+++ b/OrthancFramework/Sources/Toolbox.cpp	Tue Sep 24 09:26:42 2024 +0200
@@ -801,7 +801,6 @@
     return result;
   }
 
-
   void Toolbox::ComputeSHA1(std::string& result,
                             const void* data,
                             size_t size)
@@ -814,11 +813,13 @@
     }
 
     unsigned int digest[5];
-
     // Sanity check for the memory layout: A SHA-1 digest is 160 bits wide
-    assert(sizeof(unsigned int) == 4 && sizeof(digest) == (160 / 8)); 
+    assert(sizeof(unsigned int) == 4 && sizeof(digest) == (160 / 8));
+    assert(sizeof(boost::uuids::detail::sha1::digest_type) == 20);
     
-    sha1.get_digest(digest);
+    // From Boost 1.86, digest_type is "unsigned char[20]" while it was "unsigned int[5]"" in previous versions.
+    // Always perform the cast even if it is useless for Boost < 1.86
+    sha1.get_digest(*(reinterpret_cast<boost::uuids::detail::sha1::digest_type*>(digest)));
 
     result.resize(8 * 5 + 4);
     sprintf(&result[0], "%08x-%08x-%08x-%08x-%08x",