Fix C++11 and up compatibility for zend_finite and more

C++11 puts isfinite, isinf, isnan and a lot of other stuff into the
std namespace. Thus, if a C++11 or newer source is compiled, these
symbols won't be available. A good solution would be to include cmath,
but depending on a particular compiler that might remove even more
stuff from the global namespace, so such a fix should only target master.
For now, just keep these defines same for C++11 and upper, as the actual
C++ code should use symbols from the std namespace anyway. This
especially concerns older GCC versions like at least 4 and 5, which are
used by default in the LTS Linux distros.
This commit is contained in:
Anatol Belski 2018-07-08 20:20:08 +02:00
parent 47fb17b108
commit ad790bea2e
2 changed files with 6 additions and 6 deletions

View File

@ -70,7 +70,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
#endif
#ifndef zend_isnan
#if HAVE_DECL_ISNAN
#if HAVE_DECL_ISNAN && (!defined(__cplusplus) || __cplusplus < 201103L)
#define zend_isnan(a) isnan(a)
#elif defined(HAVE_FPCLASS)
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
@ -79,7 +79,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
#endif
#endif
#if HAVE_DECL_ISINF
#if HAVE_DECL_ISINF && (!defined(__cplusplus) || __cplusplus < 201103L)
#define zend_isinf(a) isinf(a)
#elif defined(INFINITY)
/* Might not work, but is required by ISO C99 */
@ -90,7 +90,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
#define zend_isinf(a) 0
#endif
#if HAVE_DECL_ISFINITE
#if HAVE_DECL_ISFINITE && (!defined(__cplusplus) || __cplusplus < 201103L)
#define zend_finite(a) isfinite(a)
#elif defined(HAVE_FINITE)
#define zend_finite(a) finite(a)

View File

@ -75,7 +75,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
#endif
#ifndef zend_isnan
#if HAVE_DECL_ISNAN
#if HAVE_DECL_ISNAN && (!defined(__cplusplus) || __cplusplus < 201103L)
#define zend_isnan(a) isnan(a)
#elif defined(HAVE_FPCLASS)
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
@ -84,7 +84,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
#endif
#endif
#if HAVE_DECL_ISINF
#if HAVE_DECL_ISINF && (!defined(__cplusplus) || __cplusplus < 201103L)
#define zend_isinf(a) isinf(a)
#elif defined(INFINITY)
/* Might not work, but is required by ISO C99 */
@ -95,7 +95,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
#define zend_isinf(a) 0
#endif
#if HAVE_DECL_ISFINITE
#if HAVE_DECL_ISFINITE && (!defined(__cplusplus) || __cplusplus < 201103L)
#define zend_finite(a) isfinite(a)
#elif defined(HAVE_FINITE)
#define zend_finite(a) finite(a)