From 39d43075a1c98dc0e679b85137961145a956a291 Mon Sep 17 00:00:00 2001 From: omrdk Date: Thu, 25 Jan 2024 11:24:40 +0300 Subject: [PATCH 1/3] Fix msvc2019 winx64 compile issue --- include/imageinfo.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/imageinfo.hpp b/include/imageinfo.hpp index 2049de4..9917858 100644 --- a/include/imageinfo.hpp +++ b/include/imageinfo.hpp @@ -310,7 +310,8 @@ class ReadInterface { ReadInterface(ReadFunc &read_func, size_t length) : read_func_(read_func), length_(length) { #ifndef II_DISABLE_HEADER_CACHE - header_cache_.alloc(std::min((size_t)II_HEADER_CACHE_SIZE, length)); + size_t min = length < II_HEADER_CACHE_SIZE ? length : II_HEADER_CACHE_SIZE; + header_cache_.alloc(min); read(header_cache_.data(), 0, header_cache_.size()); #endif } @@ -737,7 +738,7 @@ bool try_icns(ReadInterface &ri, size_t length, ImageInfo &info) { uint32_t entry_size = buffer.read_u32_be(4); int64_t s = size_map.at(type); entry_sizes.emplace_back(s, s); - max_size = std::max(max_size, s); + max_size = max_size > s ? max_size : s; offset += entry_size; } From ec723514044455caaeff0ca996cbfdbf8aa345ec Mon Sep 17 00:00:00 2001 From: Weihang Ding <798047000@qq.com> Date: Thu, 25 Jan 2024 21:47:44 +0800 Subject: [PATCH 2/3] Right fix for msvc --- include/imageinfo.hpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/include/imageinfo.hpp b/include/imageinfo.hpp index 9917858..51a56cc 100644 --- a/include/imageinfo.hpp +++ b/include/imageinfo.hpp @@ -30,6 +30,12 @@ #ifndef IMAGEINFO_IMAGEINFO_H #define IMAGEINFO_IMAGEINFO_H +#ifndef NOMINMAX +#define NOMINMAX +#else +#define DEFINED_NOMINMAX +#endif + #include #include #include @@ -310,8 +316,7 @@ class ReadInterface { ReadInterface(ReadFunc &read_func, size_t length) : read_func_(read_func), length_(length) { #ifndef II_DISABLE_HEADER_CACHE - size_t min = length < II_HEADER_CACHE_SIZE ? length : II_HEADER_CACHE_SIZE; - header_cache_.alloc(min); + header_cache_.alloc(std::min((size_t)II_HEADER_CACHE_SIZE, length)); read(header_cache_.data(), 0, header_cache_.size()); #endif } @@ -738,7 +743,7 @@ bool try_icns(ReadInterface &ri, size_t length, ImageInfo &info) { uint32_t entry_size = buffer.read_u32_be(4); int64_t s = size_map.at(type); entry_sizes.emplace_back(s, s); - max_size = max_size > s ? max_size : s; + max_size = std::max(max_size, s); offset += entry_size; } @@ -1193,4 +1198,8 @@ inline ImageInfo parse(InputType &input, // #pragma clang diagnostic pop #endif +#ifndef DEFINED_NOMINMAX +#undef NOMINMAX +#endif + #endif // IMAGEINFO_IMAGEINFO_H From b2f6cae8469313f2ef056bc5e393b95f23214f02 Mon Sep 17 00:00:00 2001 From: omrdk Date: Thu, 25 Jan 2024 22:35:11 +0300 Subject: [PATCH 3/3] Change std::min, and std::max presedence --- include/imageinfo.hpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/include/imageinfo.hpp b/include/imageinfo.hpp index 51a56cc..44c0897 100644 --- a/include/imageinfo.hpp +++ b/include/imageinfo.hpp @@ -30,12 +30,6 @@ #ifndef IMAGEINFO_IMAGEINFO_H #define IMAGEINFO_IMAGEINFO_H -#ifndef NOMINMAX -#define NOMINMAX -#else -#define DEFINED_NOMINMAX -#endif - #include #include #include @@ -316,7 +310,7 @@ class ReadInterface { ReadInterface(ReadFunc &read_func, size_t length) : read_func_(read_func), length_(length) { #ifndef II_DISABLE_HEADER_CACHE - header_cache_.alloc(std::min((size_t)II_HEADER_CACHE_SIZE, length)); + header_cache_.alloc((std::min)((size_t)II_HEADER_CACHE_SIZE, length)); read(header_cache_.data(), 0, header_cache_.size()); #endif } @@ -743,7 +737,7 @@ bool try_icns(ReadInterface &ri, size_t length, ImageInfo &info) { uint32_t entry_size = buffer.read_u32_be(4); int64_t s = size_map.at(type); entry_sizes.emplace_back(s, s); - max_size = std::max(max_size, s); + max_size = (std::max)(max_size, s); offset += entry_size; } @@ -1198,8 +1192,4 @@ inline ImageInfo parse(InputType &input, // #pragma clang diagnostic pop #endif -#ifndef DEFINED_NOMINMAX -#undef NOMINMAX -#endif - #endif // IMAGEINFO_IMAGEINFO_H