Fix isfinite() checks to work with all C++11 compilers
Fixes https://github.com/swig/swig/issues/615, https://github.com/swig/swig/pull/788 and https://github.com/swig/swig/pull/849.
This commit is contained in:
parent
6c8e3288ec
commit
76d1aac47a
2 changed files with 19 additions and 2 deletions
|
|
@ -5,6 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release.
|
|||
Version 3.0.11 (in progress)
|
||||
============================
|
||||
|
||||
2016-12-21: olly
|
||||
Fix isfinite() checks to work with all C++11 compilers.
|
||||
Fixes https://github.com/swig/swig/issues/615, https://github.com/swig/swig/pull/788
|
||||
and https://github.com/swig/swig/pull/849.
|
||||
|
||||
2016-12-20: wsfulton
|
||||
%namewarn unnecessarily caused keyword warnings for non-instantiated template classes
|
||||
and duplicate warnings for instantiated template classes when keywords were used.
|
||||
|
|
|
|||
|
|
@ -168,11 +168,23 @@
|
|||
%fragment("SWIG_isfinite","header",fragment="<math.h>,<float.h>") %{
|
||||
/* Getting isfinite working pre C99 across multiple platforms is non-trivial. Users can provide SWIG_isfinite on older platforms. */
|
||||
#ifndef SWIG_isfinite
|
||||
/* isfinite() is a macro for C99, but a function in namespace std for C++11. */
|
||||
/* isfinite() is a macro for C99 */
|
||||
# if defined(isfinite)
|
||||
# define SWIG_isfinite(X) (isfinite(X))
|
||||
# elif defined __cplusplus && __cplusplus >= 201103L
|
||||
# define SWIG_isfinite(X) (std::isfinite(X))
|
||||
/* Use a template so that this works whether isfinite() is std::isfinite() or
|
||||
* in the global namespace. The reality seems to vary between compiler
|
||||
* versions.
|
||||
*
|
||||
* Make sure namespace std exists to avoid compiler warnings.
|
||||
*/
|
||||
namespace std { }
|
||||
template<typename T>
|
||||
inline int SWIG_isfinite_func(T x) {
|
||||
using namespace std;
|
||||
return isfinite(x);
|
||||
}
|
||||
# define SWIG_isfinite(X) (SWIG_isfinite_func(X))
|
||||
# elif defined(_MSC_VER)
|
||||
# define SWIG_isfinite(X) (_finite(X))
|
||||
# elif defined(__sun) && defined(__SVR4)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue