From 2a690a135bf62feb8afb0d4b200df0c74b15183c Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Thu, 26 Jan 2023 15:22:53 -0800 Subject: [PATCH] use gnu_printf Fixes warning under MinGW: warning: unknown conversion type character 'z' in format [-Wformat=] Signed-off-by: Rosen Penev --- src/CMakeLists.txt | 5 ----- src/image_int.hpp | 4 +++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index be971600..bc3c18c0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -158,11 +158,6 @@ endif() # Other library target properties # --------------------------------------------------------- -if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU) - # Do not check format overflows on this file, to skip a false positive warning - set_source_files_properties(value.cpp PROPERTIES COMPILE_FLAGS -Wno-format-overflow) -endif() - set_target_properties( exiv2lib PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MINOR} diff --git a/src/image_int.hpp b/src/image_int.hpp index 77ab5eda..e7c90785 100644 --- a/src/image_int.hpp +++ b/src/image_int.hpp @@ -12,7 +12,9 @@ #include // for ostream, basic_ostream::put #include -#if (defined(__GNUG__) || defined(__GNUC__)) || defined(__clang__) +#if defined(__MINGW32__) +#define ATTRIBUTE_FORMAT_PRINTF __attribute__((format(__MINGW_PRINTF_FORMAT, 1, 0))) +#elif defined(__GNUC__) #define ATTRIBUTE_FORMAT_PRINTF __attribute__((format(printf, 1, 0))) #else #define ATTRIBUTE_FORMAT_PRINTF