Anton Samsonov has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/77089?usp=email )
Change subject: Remove dependency on C23 __has_include() ......................................................................
Remove dependency on C23 __has_include()
Clang, GCC and C23-aware compilers will still use `__has_include()` to check for header presence. Old and alternative compilers will fall back to unconditional inclusion, unless user-supplied macros `HAVE_GETOPT_H` and `HAVE_PCIUTILS_PCI_H` are defined as 1 or 0.
Change-Id: Ic544963ffd29626ae0a21bdddb1c78850cc43ec6 Signed-off-by: Anton Samsonov devel@zxlab.ru --- M include/cli_classic.h M include/platform/pci.h 2 files changed, 22 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/89/77089/1
diff --git a/include/cli_classic.h b/include/cli_classic.h index e651cc6..7e2848b 100644 --- a/include/cli_classic.h +++ b/include/cli_classic.h @@ -15,9 +15,21 @@ #ifndef CLI_CLASSIC_H #define CLI_CLASSIC_H
-#if __has_include(<getopt.h>) +#if HAVE_GETOPT_H #include <getopt.h> +#elif !defined(HAVE_GETOPT_H) +#if !defined(__has_include) && (__STDC_VERSION__ < 202300L) +#include <getopt.h> +#define HAVE_GETOPT_H 1 +#elif __has_include(<getopt.h>) +#include <getopt.h> +#define HAVE_GETOPT_H 1 #else +#define HAVE_GETOPT_H 0 +#endif /* __has_include() */ +#endif /* HAVE_GETOPT_H */ + +#if !HAVE_GETOPT_H
#define no_argument 0 #define required_argument 1 @@ -39,5 +51,5 @@ int getopt_long_only (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind);
-#endif /* __has_include() */ +#endif /* HAVE_GETOPT_H */ #endif /* CLI_CLASSIC_H */ diff --git a/include/platform/pci.h b/include/platform/pci.h index 4ac108f..5e350ac 100644 --- a/include/platform/pci.h +++ b/include/platform/pci.h @@ -22,10 +22,16 @@ * e.g. NetBSD 9.0 on sparc64 pciutils-3.7.0nb2. * Other NetBSD platforms and versions uses the default path under pci/pci.h */ -#if __has_include(<pciutils/pci.h>) +#if !defined(__has_include) && (__STDC_VERSION__ < 202300L) +#if HAVE_PCIUTILS_PCI_H #include <pciutils/pci.h> #else #include <pci/pci.h> -#endif +#endif /* HAVE_PCIUTILS_PCI_H */ +#elif __has_include(<pciutils/pci.h>) +#include <pciutils/pci.h> +#else +#include <pci/pci.h> +#endif /* __has_include(<pciutils/pci.h>) */
#endif /* __PLATFORM_PCI_H__ */