aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2021-12-26 18:19:41 +0100
committerMartin Mares <mj@ucw.cz>2021-12-28 16:26:26 +0100
commit4658bfad1878c47e2cb6a42ec5dbd9b0ad6739dd (patch)
treed0ab0ede04f9967349b4c4b612d3a27e67963b45
parentad1401686f184e044d03fb47d6c48edc519ed628 (diff)
downloadpciutils-4658bfad1878c47e2cb6a42ec5dbd9b0ad6739dd.tar.gz
pciutils: Do not include compat/getopt.h on MinGW32 >= 3.0
MinGW32 since version 3.0 declares getopt() function prototype in <unistd.h> header file.
-rw-r--r--pciutils.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/pciutils.h b/pciutils.h
index 3c5fac6..17e02c9 100644
--- a/pciutils.h
+++ b/pciutils.h
@@ -9,7 +9,20 @@
#include "lib/pci.h"
#include "lib/sysdep.h"
-#ifdef PCI_OS_WINDOWS
+/*
+ * gcc predefines macro __MINGW32__ for all MinGW targets.
+ * Including some MinGW header (e.g. windef.h) defines additional
+ * macro __MINGW32_MAJOR_VERSION (available for all MinGW targets).
+ */
+#if defined(PCI_OS_WINDOWS) && defined(__MINGW32__)
+#include <windef.h>
+#endif
+
+/*
+ * On Windows only MinGW 3.0 and higher versions provides <getopt.h>
+ * header file. Older MinGW versions and MSVC do not have it.
+ */
+#if defined(PCI_OS_WINDOWS) && !(defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 3)
#include "compat/getopt.h"
#else
#include <unistd.h>