github.com/256dpi/max-go@v0.7.0/lib/max/ext_common.h (about) 1 /* common.h -- those things we define often */ 2 #ifndef _EXT_COMMON_H_ 3 #define _EXT_COMMON_H_ 4 5 #include "ext_infer_system.h" 6 7 #ifdef WIN_VERSION 8 #define C74_EXPORT __declspec(dllexport) 9 #define C74_HIDDEN 10 #define C74_MUST_CHECK 11 #else // MAC_VERSION 12 13 #define C74_EXPORT __attribute__((visibility("default"))) 14 #define C74_HIDDEN __attribute__((visibility("hidden"))) 15 16 /** If the result of a function is unused, force a compiler warning about it. */ 17 #define C74_MUST_CHECK __attribute__((warn_unused_result)) 18 19 #endif 20 21 22 #if C74_NO_CONST 23 #define C74_CONST 24 #else 25 #define C74_CONST const 26 #endif 27 28 #ifdef C74_NO_DEPRECATION 29 #define C74_DEPRECATED(func) func 30 #endif 31 32 #ifndef C74_DEPRECATED 33 #ifdef __GNUC__ 34 #define C74_DEPRECATED(func) func __attribute__ ((deprecated)) 35 #elif defined(_MSC_VER) 36 #define C74_DEPRECATED(func) __declspec(deprecated) func 37 #else 38 #define C74_DEPRECATED(func) func 39 #endif 40 #endif // C74_DEPRECATED 41 42 43 /** 44 If a value is within the specified range, then return true. Otherwise return false. 45 46 @ingroup misc 47 @param v The value to test. 48 @param lo The low bound for the range. 49 @param hi The high bound for the range. 50 @return Returns true if within range, otherwise false. 51 */ 52 #define INRANGE(v,lo,hi) ((v)<=(hi)&&(v)>=(lo)) 53 54 55 /** 56 Return the higher of two values. 57 58 @ingroup misc 59 @param a The first value to compare. 60 @param b The second value to compare. 61 @return Returns the higher of a or b. 62 */ 63 #ifndef MAX 64 #define MAX(a,b) ((a)>(b)?(a):(b)) 65 #endif 66 67 68 /** 69 Return the lower of two values. 70 71 @ingroup misc 72 @param a The first value to compare. 73 @param b The second value to compare. 74 @return Returns the lower of a or b. 75 */ 76 #ifndef MIN 77 #define MIN(a,b) ((a)<(b)?(a):(b)) 78 #endif 79 80 81 /** 82 Limit values to within a specified range. 83 84 @ingroup misc 85 @param a The value to constrain. NB: CLIP_ASSIGN modifies param 'a' but CLAMP only returns limited value 86 @param lo The low bound for the range. 87 @param hi The high bound for the range. 88 @return Returns the value a constrained to the range specified by lo and hi. 89 */ 90 #define CLAMP(a, lo, hi) ( (a)>(lo)?( (a)<(hi)?(a):(hi) ):(lo) ) 91 #define CLIP_ASSIGN(a, lo, hi) ((a) = ( (a)>(lo)?( (a)<(hi)?(a):(hi) ):(lo) )) 92 93 #ifndef ABS 94 #define ABS(x) ((x)<0?-(x):(x)) 95 #endif 96 97 #if defined(MAC_VERSION) || defined(LINUX_VERSION) 98 #define strcmp_case_insensitive strcasecmp 99 #endif 100 #ifdef WIN_VERSION 101 #if _MSC_VER < 1400 102 #define strcmp_case_insensitive strcmpi 103 #else 104 #define strcmp_case_insensitive _strcmpi 105 #endif 106 #endif 107 108 #endif /* _EXT_COMMON_H_ */