Make it compile with C++11 support.

Reference : https://bugs.webkit.org/show_bug.cgi?id=59249
This commit is contained in:
Julien de Kozak 2014-11-01 18:35:44 +01:00 committed by Robin Gareus
parent 036b6234ac
commit cb8abbe8d2
4 changed files with 39 additions and 15 deletions

View file

@ -17,14 +17,17 @@
*/ */
#include <cmath>
#ifdef COMPILER_MSVC #ifdef COMPILER_MSVC
#include <float.h> #include <float.h>
/* isinf() & isnan() are C99 standards, which older MSVC doesn't provide */
#define isinf(val) !((bool)_finite((double)val)) // 'std::isnan()' is not available in MSVC.
#define isnan(val) (bool)_isnan((double)val) #define isnan_local(val) (bool)_isnan((double)val)
#else
#define isnan_local std::isnan
#endif #endif
#include <cmath>
#include <climits> #include <climits>
#include <vector> #include <vector>
#include <fstream> #include <fstream>
@ -976,7 +979,7 @@ AutomationLine::reset_callback (const Evoral::ControlList& events)
model_to_view_coord (tx, ty); model_to_view_coord (tx, ty);
if (isnan (tx) || isnan (ty)) { if (isnan_local (tx) || isnan_local (ty)) {
warning << string_compose (_("Ignoring illegal points on AutomationLine \"%1\""), warning << string_compose (_("Ignoring illegal points on AutomationLine \"%1\""),
_name) << endmsg; _name) << endmsg;
continue; continue;

View file

@ -16,6 +16,18 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <cmath>
#ifdef COMPILER_MSVC
#include <float.h>
// 'std::isinf()' and 'std::isnan()' are not available in MSVC.
#define isinf_local(val) !((bool)_finite((double)val))
#define isnan_local(val) (bool)_isnan((double)val)
#else
#define isinf_local std::isinf
#define isnan_local std::isnan
#endif
#include "pbd/ffs.h" #include "pbd/ffs.h"
#include "pbd/enumwriter.h" #include "pbd/enumwriter.h"
@ -647,9 +659,9 @@ MidiTrack::MidiControl::set_value(double val)
const Evoral::Parameter &parameter = _list ? _list->parameter() : Control::parameter(); const Evoral::Parameter &parameter = _list ? _list->parameter() : Control::parameter();
bool valid = false; bool valid = false;
if (isinf(val)) { if (isinf_local(val)) {
cerr << "MIDIControl value is infinity" << endl; cerr << "MIDIControl value is infinity" << endl;
} else if (isnan(val)) { } else if (isnan_local(val)) {
cerr << "MIDIControl value is NaN" << endl; cerr << "MIDIControl value is NaN" << endl;
} else if (val < parameter.min()) { } else if (val < parameter.min()) {
cerr << "MIDIControl value is < " << parameter.min() << endl; cerr << "MIDIControl value is < " << parameter.min() << endl;

View file

@ -17,6 +17,16 @@
*/ */
#include <cmath> #include <cmath>
#ifdef COMPILER_MSVC
#include <float.h>
// 'std::isnan()' is not available in MSVC.
#define isnan_local(val) (bool)_isnan((double)val)
#else
#define isnan_local std::isnan
#endif
#include <cassert> #include <cassert>
#include <utility> #include <utility>
#include <iostream> #include <iostream>
@ -837,8 +847,7 @@ ControlList::modify (iterator iter, double when, double val)
(*iter)->when = when; (*iter)->when = when;
(*iter)->value = val; (*iter)->value = val;
if (isnan_local (val)) {
if (isnan (val)) {
abort (); abort ();
} }

View file

@ -40,11 +40,11 @@
#include <float.h> #include <float.h>
// 'std::isinf()' and 'std::isnan()' are not available in MSVC. // 'std::isinf()' and 'std::isnan()' are not available in MSVC.
#define isinf(val) !((bool)_finite((double)val)) #define isinf_local(val) !((bool)_finite((double)val))
#define isnan(val) (bool)_isnan((double)val) #define isnan_local(val) (bool)_isnan((double)val)
#else #else
using std::isnan; #define isinf_local std::isinf
using std::isinf; #define isnan_local std::isnan
#endif #endif
#include "SpectralCentroid.h" #include "SpectralCentroid.h"
@ -176,13 +176,13 @@ SpectralCentroid::process(const float *const *inputBuffers, Vamp::RealTime)
Feature feature; Feature feature;
feature.hasTimestamp = false; feature.hasTimestamp = false;
if (!isnan(centroidLog) && !isinf(centroidLog)) { if (!isnan_local(centroidLog) && !isinf_local(centroidLog)) {
feature.values.push_back(centroidLog); feature.values.push_back(centroidLog);
} }
returnFeatures[0].push_back(feature); returnFeatures[0].push_back(feature);
feature.values.clear(); feature.values.clear();
if (!isnan(centroidLin) && !isinf(centroidLin)) { if (!isnan_local(centroidLin) && !isinf_local(centroidLin)) {
feature.values.push_back(centroidLin); feature.values.push_back(centroidLin);
} }
returnFeatures[1].push_back(feature); returnFeatures[1].push_back(feature);