From 8ed193d254b5c3d603424072f10a59ca59f76305 Mon Sep 17 00:00:00 2001 From: s1lentq Date: Wed, 13 Dec 2023 19:14:01 +0700 Subject: [PATCH] fix linux build --- regamedll/public/utlarray.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/regamedll/public/utlarray.h b/regamedll/public/utlarray.h index a65fd9b8e..fa0f22fa8 100644 --- a/regamedll/public/utlarray.h +++ b/regamedll/public/utlarray.h @@ -76,7 +76,12 @@ class CUtlArray // sort using std:: and expecting a "<" function to be defined for the type void Sort(); void Sort(bool (*pfnLessFunc)(const T &src1, const T &src2)); + +#if defined(_WIN32) void Sort(int (__cdecl *pfnCompare)(const T *, const T *)); +#else + void Sort(int (*pfnCompare)(const T *, const T *)); +#endif // sort using std:: with a predicate. e.g. [] -> bool (const T &a, const T &b) const { return a < b; } template @@ -211,6 +216,8 @@ void CUtlArray::Sort(bool (*pfnLessFunc)(const T &src1, const T &sr }); } +#if defined(_WIN32) + template void CUtlArray::Sort(int (__cdecl *pfnCompare)(const T *, const T *)) { @@ -221,6 +228,19 @@ void CUtlArray::Sort(int (__cdecl *pfnCompare)(const T *, const T * qsort(Base(), Count(), sizeof(T), (QSortCompareFunc_t)(pfnCompare)); } +#else // #if defined(_LINUX) + +template +void CUtlArray::Sort(int (*pfnCompare)(const T *, const T *)) +{ + typedef int (*QSortCompareFunc_t)(const void *, const void *); + if (Count() <= 1) + return; + + qsort(Base(), Count(), sizeof(T), (QSortCompareFunc_t)(pfnCompare)); +} +#endif // #if defined(_LINUX) + template template void CUtlArray::SortPredicate(F &&predicate)