From a7aeaad9b01ffd663f8efbda2cce2416a7d00796 Mon Sep 17 00:00:00 2001 From: Hib Eris Date: Sat, 1 Jun 2013 12:05:17 +0200 Subject: [PATCH] Use ansi stdio extensions when using a mingw compiler In the C runtime used by mingw compilers (msvcrt.dll) the printf function does not support the C99 format-width specifier "%ll". Defining __USE_MINGW_ANSI_STDIO enables mingw's ansi stdio extensions that implement a C99 compliant printf function. https://bugs.freedesktop.org/show_bug.cgi?id=65238 --- CMakeLists.txt | 4 ++++ configure.ac | 3 +++ poppler/poppler-config.h.in | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index baafed3..cf2bb2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,6 +161,10 @@ if(ENABLE_LIBCURL) endif(ENABLE_LIBCURL) add_definitions(-DHAVE_CONFIG_H=1) +if(MINGW) + # Use mingw's ansi stdio extensions + add_definitions(-D__USE_MINGW_ANSI_STDIO=1) +endif(MINGW) if(FONTCONFIG_FOUND) add_definitions(${FONTCONFIG_DEFINITIONS}) include_directories(${FONTCONFIG_INCLUDE_DIR}) diff --git a/configure.ac b/configure.ac index 09fa425..3b4c493 100644 --- a/configure.ac +++ b/configure.ac @@ -66,6 +66,9 @@ case "$host_os" in win32_libs="-lgdi32" create_shared_lib="-no-undefined" auto_import_flags="-Wl,--enable-auto-import" + + # Use mingw's ansi stdio extensions + CXXFLAGS="$CXXFLAGS -D__USE_MINGW_ANSI_STDIO=1" ;; esac diff --git a/poppler/poppler-config.h.in b/poppler/poppler-config.h.in index 11b5691..51705e8 100644 --- a/poppler/poppler-config.h.in +++ b/poppler/poppler-config.h.in @@ -158,8 +158,13 @@ char * strtok_r (char *s, const char *delim, char **save_ptr); //------------------------------------------------------------------------ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) +#ifdef __USE_MINGW_ANSI_STDIO +#define GCC_PRINTF_FORMAT(fmt_index, va_index) \ + __attribute__((__format__(__MINGW_PRINTF_FORMAT, fmt_index, va_index))) +#else #define GCC_PRINTF_FORMAT(fmt_index, va_index) \ __attribute__((__format__(__printf__, fmt_index, va_index))) +#endif #else #define GCC_PRINTF_FORMAT(fmt_index, va_index) #endif -- 1.8.1.2