From 4658bfad1878c47e2cb6a42ec5dbd9b0ad6739dd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pali=20Roh=C3=A1r?= Date: Sun, 26 Dec 2021 18:19:41 +0100 Subject: [PATCH] pciutils: Do not include compat/getopt.h on MinGW32 >= 3.0 MinGW32 since version 3.0 declares getopt() function prototype in header file. --- pciutils.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 +#endif + +/* + * On Windows only MinGW 3.0 and higher versions provides + * 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 -- 2.39.5