diff --git a/cl_dll/cl_dll.h b/cl_dll/cl_dll.h index 6ba3db67..232df68e 100644 --- a/cl_dll/cl_dll.h +++ b/cl_dll/cl_dll.h @@ -31,7 +31,8 @@ typedef unsigned char byte; typedef unsigned short word; typedef float vec_t; -typedef int ( *pfnUserMsgHook )( const char *pszName, int iSize, void *pbuf ); +// redefine +//typedef int ( *pfnUserMsgHook )( const char *pszName, int iSize, void *pbuf ); #include "util_vector.h" @@ -43,7 +44,11 @@ typedef int ( *pfnUserMsgHook )( const char *pszName, int iSize, void *pbuf ); #endif #include "exportdef.h" #include - +#if HAVE_CMATH +#include +#else +#include +#endif #if defined(__LP64__) || defined(__LLP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) #define XASH_64BIT #endif diff --git a/cl_dll/util_vector.h b/cl_dll/util_vector.h index 93166a6b..c83d347f 100644 --- a/cl_dll/util_vector.h +++ b/cl_dll/util_vector.h @@ -22,8 +22,11 @@ // Misc C-runtime library headers #include #include +#if HAVE_CMATH #include - +#else +#include +#endif // Header file containing definition of globalvars_t and entvars_t typedef unsigned int func_t; // typedef int string_t; // from engine's pr_comp.h; diff --git a/common/mathlib.h b/common/mathlib.h index afe44352..62f04d93 100644 --- a/common/mathlib.h +++ b/common/mathlib.h @@ -22,7 +22,11 @@ #include #endif // HAVE_TGMATH_H #else // __cplusplus +#if HAVE_CMATH #include +#else +#include +#endif #endif // __cplusplus typedef float vec_t; diff --git a/dlls/extdll.h b/dlls/extdll.h index eb8c37ec..1f932dc7 100644 --- a/dlls/extdll.h +++ b/dlls/extdll.h @@ -66,7 +66,11 @@ typedef int BOOL; #include #include #include +#if HAVE_CMATH #include +#else +#include +#endif #ifndef M_PI_F #define M_PI_F (float)M_PI diff --git a/wscript b/wscript index 0e98480f..b01647df 100644 --- a/wscript +++ b/wscript @@ -249,10 +249,16 @@ def configure(conf): conf.define_cond('HAVE_TGMATH_H', tgmath_usable) else: conf.undefine('HAVE_TGMATH_H') + cmath_usable = conf.check_cxx(fragment='''#include + int main(void){ return (int)sqrt(2.0f); }''', + msg='Checking if cmath is usable', mandatory = False) + conf.define_cond('HAVE_CMATH', cmath_usable) if conf.env.COMPILER_CC == 'msvc': conf.define('_CRT_SECURE_NO_WARNINGS', 1) conf.define('_CRT_NONSTDC_NO_DEPRECATE', 1) + elif conf.env.COMPILER_CC == 'owcc': + pass else: conf.env.append_unique('DEFINES', ['stricmp=strcasecmp', 'strnicmp=strncasecmp', '_snprintf=snprintf', '_vsnprintf=vsnprintf', '_LINUX', 'LINUX']) conf.env.append_unique('CXXFLAGS', ['-Wno-invalid-offsetof', '-fno-rtti', '-fno-exceptions'])