Skip to content

Commit ad790be

Browse files
committed
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.
1 parent 47fb17b commit ad790be

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Zend/configure.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
7070
#endif
7171

7272
#ifndef zend_isnan
73-
#if HAVE_DECL_ISNAN
73+
#if HAVE_DECL_ISNAN && (!defined(__cplusplus) || __cplusplus < 201103L)
7474
#define zend_isnan(a) isnan(a)
7575
#elif defined(HAVE_FPCLASS)
7676
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
@@ -79,7 +79,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
7979
#endif
8080
#endif
8181

82-
#if HAVE_DECL_ISINF
82+
#if HAVE_DECL_ISINF && (!defined(__cplusplus) || __cplusplus < 201103L)
8383
#define zend_isinf(a) isinf(a)
8484
#elif defined(INFINITY)
8585
/* Might not work, but is required by ISO C99 */
@@ -90,7 +90,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
9090
#define zend_isinf(a) 0
9191
#endif
9292

93-
#if HAVE_DECL_ISFINITE
93+
#if HAVE_DECL_ISFINITE && (!defined(__cplusplus) || __cplusplus < 201103L)
9494
#define zend_finite(a) isfinite(a)
9595
#elif defined(HAVE_FINITE)
9696
#define zend_finite(a) finite(a)

configure.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
7575
#endif
7676
7777
#ifndef zend_isnan
78-
#if HAVE_DECL_ISNAN
78+
#if HAVE_DECL_ISNAN && (!defined(__cplusplus) || __cplusplus < 201103L)
7979
#define zend_isnan(a) isnan(a)
8080
#elif defined(HAVE_FPCLASS)
8181
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
@@ -84,7 +84,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
8484
#endif
8585
#endif
8686
87-
#if HAVE_DECL_ISINF
87+
#if HAVE_DECL_ISINF && (!defined(__cplusplus) || __cplusplus < 201103L)
8888
#define zend_isinf(a) isinf(a)
8989
#elif defined(INFINITY)
9090
/* Might not work, but is required by ISO C99 */
@@ -95,7 +95,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
9595
#define zend_isinf(a) 0
9696
#endif
9797
98-
#if HAVE_DECL_ISFINITE
98+
#if HAVE_DECL_ISFINITE && (!defined(__cplusplus) || __cplusplus < 201103L)
9999
#define zend_finite(a) isfinite(a)
100100
#elif defined(HAVE_FINITE)
101101
#define zend_finite(a) finite(a)

0 commit comments

Comments
 (0)