X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=msvc_extra_headers%2Fardourext%2Fmisc.h.input;h=9bcba6f327dacd8d13762db2f0bd815ae9c42674;hb=341758674b1c6b6e38bfe9e59e04062a70adca86;hp=55eb529f24b9579a47e97fe8120aebd6074db421;hpb=6a436fd826d1c9d88b60287696cc0836ccce35aa;p=ardour.git diff --git a/msvc_extra_headers/ardourext/misc.h.input b/msvc_extra_headers/ardourext/misc.h.input index 55eb529f24..9bcba6f327 100644 --- a/msvc_extra_headers/ardourext/misc.h.input +++ b/msvc_extra_headers/ardourext/misc.h.input @@ -27,7 +27,10 @@ #define _CPP_VECTOR 1 #endif +#ifdef __cplusplus #include +#endif + #include #include #include @@ -36,10 +39,10 @@ #include // '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 @@ -60,6 +63,7 @@ #define getcwd _getcwd #define getpid _getpid #define snprintf _snprintf +#define random rand #define link ntfs_link #define unlink ntfs_unlink #define strcasecmp stricmp @@ -70,11 +74,6 @@ #ifndef PATH_MAX #define PATH_MAX _MAX_PATH #endif -#define DECLARE_DEFAULT_COMPARISONS(Type) \ - extern bool operator > (const Type& lhs, const Type& rhs); \ - extern bool operator < (const Type& lhs, const Type& rhs); \ - extern bool operator != (const Type& lhs, const Type& rhs); \ - extern bool operator == (const Type& lhs, const Type& rhs); // Types missing from Win32 'stat.h' (hopefully Windows // will either act sensibly or ignore most of them). @@ -171,15 +170,12 @@ 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 -// concept of a system-wide (or programmable) rounding direction. -// 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) // System V compatibility typedef unsigned short ushort; @@ -195,6 +191,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 int64_t abs(int64_t val) throw() +{ + 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,8 +217,18 @@ typedef _mode_t mode_t; // #include the main headers for Ardour MSVC -#if defined(BUILDING_PBD) || defined(PBD_IS_IN_WIN_STATIC_LIB) +#ifdef __cplusplus +#if defined(LIBPBD_DLL) || defined(PBD_IS_IN_WIN_STATIC_LIB) #include + +#ifdef LIBPBD_DLL +#define DEFAULT_COMPARISONS_DEFINED +#define DECLARE_DEFAULT_COMPARISONS(Type) \ + LIBPBD_API bool operator > (const Type& lhs, const Type& rhs); \ + LIBPBD_API bool operator < (const Type& lhs, const Type& rhs); \ + LIBPBD_API bool operator != (const Type& lhs, const Type& rhs); \ + LIBPBD_API bool operator == (const Type& lhs, const Type& rhs); +#endif #endif #if defined(BUILDING_LIBARDOUR) || defined(LIBARDOUR_IS_IN_WIN_STATIC_LIB) #include @@ -219,5 +236,23 @@ typedef _mode_t mode_t; #if defined(BUILDING_RUBBERBAND) || defined(RUBBERBAND_IS_IN_WIN_STATIC_LIB) #include #endif +#endif // __cplusplus + +#ifndef DEFAULT_COMPARISONS_DEFINED +#define DEFAULT_COMPARISONS_DEFINED +#define DECLARE_DEFAULT_COMPARISONS(Type) \ + extern bool operator > (const Type& lhs, const Type& rhs); \ + extern bool operator < (const Type& lhs, const Type& rhs); \ + extern bool operator != (const Type& lhs, const Type& rhs); \ + extern bool operator == (const Type& lhs, const Type& rhs); +#endif + +#if !defined(LIBPBD_API) || defined(PBD_IS_IN_WIN_STATIC_LIB) +extern double round(double x); + +// log2().... MSVC doesn't offer the C99 function 'log2()' +// so let's emulate it. +extern double log2(double x); +#endif #endif /* __ardour_msvc_extensions_h__ */