From 8087f603ad42c15a1dd83eda1e4e077024fc8f44 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Wed, 16 Dec 2020 17:06:48 +0100 Subject: [PATCH] Stub out __has_attribute if not defined Otherwise compilers that don't even have __has_attribute fail. Fixes #7554 --- config_cmake.h.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config_cmake.h.in b/config_cmake.h.in index 2a8532d2f..4dbf7520e 100644 --- a/config_cmake.h.in +++ b/config_cmake.h.in @@ -181,7 +181,13 @@ /* Like __warn_unused, but applies to a type. At the moment only clang supports this as a type attribute. + + We need to check for __has_attribute being a thing before or old gcc fails - #7554. */ +#ifndef __has_attribute + #define __has_attribute(x) 0 // Compatibility with non-clang and old gcc compilers. +#endif + #if defined(__clang__) && __has_attribute(warn_unused_result) #ifndef __warn_unused_type #define __warn_unused_type __attribute__ ((warn_unused_result))