Use macro to detect real gcc as opposed to e.g. clang disguising as gcc

This commit is contained in:
Jean-Francois Dockes 2021-08-17 09:16:55 +02:00
parent ce0352eff4
commit 3cd8506ff8

View File

@ -67,7 +67,14 @@ typedef int ssize_t;
# define PRETEND_USE(expr) ((void)(expr))
#endif /* PRETEND_USE */
#ifdef __GNUC__
// It's complicated to really detect gnu gcc because other compilers define __GNUC__
// See stackoverflow questions/38499462/how-to-tell-clang-to-stop-pretending-to-be-other-compilers
#if defined(__GNUC__) && !defined(__llvm__) && !defined(__INTEL_COMPILER)
#define REAL_GCC __GNUC__ // probably
#endif
#ifdef REAL_GCC
// Older gcc versions pretended to supply std::regex, but the resulting programs mostly crashed.
#include <features.h>
#if ! __GNUC_PREREQ(6,0)
#define NO_STD_REGEX 1