Merge branch 'master' into windows
[ardour.git] / msvc_extra_headers / ardourext / misc.h.input
index 55eb529f24b9579a47e97fe8120aebd6074db421..63ce6c562c8cef006eb22c9ce92143c4698dfcae 100644 (file)
 #define _CPP_VECTOR  1
 #endif
 
+#ifdef __cplusplus
 #include <vector>
+#endif
+
 #include <math.h>
 #include <float.h>
 #include <direct.h>
 #include <ardourext/float_cast.h>
 
 // 'std::isnan()' is not available in MSVC. Assume '_isnan(double)'
-#define isnan(val) (bool)_isnan((double)val)
+#define isnan(val)  _isnan((double)val)
 
 // 'std::isinf()' is not available in MSVC. Assume '!_finite(double)'
-#define isinf(val) !((bool)_finite((double)val))
+#define isinf(val) !_finite((double)val)
 
 // 'INFINITY' is not defined in MSVC. Assume 'HUGE_VAL'
 #ifndef INFINITY
@@ -171,7 +174,11 @@ typedef int register_t;
 
 // throw()
 #ifndef __THROW
+#ifdef __cplusplus
 #define __THROW  throw()
+#else
+#define __THROW
+#endif
 #endif
 
 // round().... Unlike Linux, Windows doesn't seem to support the
@@ -179,7 +186,9 @@ typedef int register_t;
 // Fortunately, 'round to nearest' seems to be the default action
 // under Linux, so let's copy that until we find out otherwise.
 #define rint(value)  round(value)
-#define round(value) floor((value) + 0.5)
+#if !defined(PBD_API) || defined(PBD_IS_IN_WIN_STATIC_LIB)
+extern  double round(double x);
+#endif
 
 // System V compatibility
 typedef unsigned short ushort;
@@ -195,6 +204,17 @@ typedef _mode_t mode_t;
 #endif /* NO_OLDNAMES */
 #endif /* _MODE_T_ */
 
+// int64 abs()
+#ifdef __cplusplus // Normal 'C' doesn't permit over-ridden functions !!
+inline uint64_t abs(int64_t val)
+{
+       if (val < 0)
+               return val * (-1);
+       else
+               return val;
+}
+#endif
+
 // fmin() and fmax()
 #define fmin(a, b) min((double)a, (double)b)
 #define fmax(a, b) max((double)a, (double)b)
@@ -210,6 +230,7 @@ typedef _mode_t mode_t;
 
 
 // #include the main headers for Ardour MSVC
+#ifdef __cplusplus
 #if defined(BUILDING_PBD) || defined(PBD_IS_IN_WIN_STATIC_LIB)
 #include <pbd/msvc_pbd.h>
 #endif
@@ -219,5 +240,6 @@ typedef _mode_t mode_t;
 #if defined(BUILDING_RUBBERBAND) || defined(RUBBERBAND_IS_IN_WIN_STATIC_LIB)
 #include <rubberband/msvc_rubberband.h>
 #endif
+#endif // __cplusplus
 
 #endif /* __ardour_msvc_extensions_h__ */