Fix mingw warnings
diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 0b2b010..7b0f8cd 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -3510,7 +3510,7 @@
}
void AnnotTextMarkup::setType(AnnotSubtype new_type) {
- const char *typeName;
+ const char *typeName = nullptr; /* squelch bogus compiler warning */
switch (new_type) {
case typeHighlight:
@@ -5307,7 +5307,7 @@
}
void AnnotGeometry::setType(AnnotSubtype new_type) {
- const char *typeName;
+ const char *typeName = nullptr; /* squelch bogus compiler warning */
switch (new_type) {
case typeSquare:
@@ -5565,7 +5565,7 @@
}
void AnnotPolygon::setType(AnnotSubtype new_type) {
- const char *typeName;
+ const char *typeName = nullptr; /* squelch bogus compiler warning */
switch (new_type) {
case typePolygon:
diff --git a/poppler/DCTStream.cc b/poppler/DCTStream.cc
index b3e1303..938e18a 100644
--- a/poppler/DCTStream.cc
+++ b/poppler/DCTStream.cc
@@ -228,8 +228,10 @@
}
int DCTStream::getChars(int nChars, Guchar *buffer) {
- int c;
- for (int i = 0; i < nChars; ++i) {
+ // Use volatile to prevent the compiler optimizing
+ // variables into registers. See setjmp man page.
+ volatile int i, c;
+ for (i = 0; i < nChars; ++i) {
DO_GET_CHAR
if (likely(c != EOF)) buffer[i] = c;
else return i;
diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc
index 8da2817..31a9957 100644
--- a/poppler/GlobalParams.cc
+++ b/poppler/GlobalParams.cc
@@ -134,20 +134,25 @@
static HMODULE hmodule;
extern "C" {
-BOOL WINAPI
-DllMain (HINSTANCE hinstDLL,
- DWORD fdwReason,
- LPVOID lpvReserved)
-{
- switch (fdwReason)
- {
- case DLL_PROCESS_ATTACH:
- hmodule = hinstDLL;
- break;
+ /* Provide declaration to squelch -Wmissing-declarations warning */
+ BOOL WINAPI
+ DllMain (HINSTANCE hinstDLL,
+ DWORD fdwReason,
+ LPVOID lpvReserved);
+
+ BOOL WINAPI
+ DllMain (HINSTANCE hinstDLL,
+ DWORD fdwReason,
+ LPVOID lpvReserved)
+ {
+ switch (fdwReason) {
+ case DLL_PROCESS_ATTACH:
+ hmodule = hinstDLL;
+ break;
}
- return TRUE;
-}
+ return TRUE;
+ }
}
static const char *
diff --git a/poppler/XRef.cc b/poppler/XRef.cc
index 38e2768..69870bd 100644
--- a/poppler/XRef.cc
+++ b/poppler/XRef.cc
@@ -32,6 +32,7 @@
//========================================================================
#include <config.h>
+#include "poppler-config.h"
#ifdef USE_GCC_PRAGMAS
#pragma implementation
diff --git a/poppler/poppler-config.h.cmake b/poppler/poppler-config.h.cmake
index 0e806f4..2e8cb0d 100644
--- a/poppler/poppler-config.h.cmake
+++ b/poppler/poppler-config.h.cmake
@@ -25,8 +25,6 @@
#ifndef POPPLER_CONFIG_H
#define POPPLER_CONFIG_H
-#include <stdio.h>
-
// We duplicate some of the config.h #define's here since they are
// used in some of the header files we install. The #ifndef/#endif
// around #undef look odd, but it's to silence warnings about
@@ -148,6 +146,7 @@
//------------------------------------------------------------------------
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
+#include <stdio.h> // __MINGW_PRINTF_FORMAT is defined in the mingw stdio.h
#ifdef __MINGW_PRINTF_FORMAT
#define GCC_PRINTF_FORMAT(fmt_index, va_index) \
__attribute__((__format__(__MINGW_PRINTF_FORMAT, fmt_index, va_index)))