From 7a1e891d456cfaeb41d4c64c5007205e9b7793bf Mon Sep 17 00:00:00 2001 From: bfs2021 <101915083+bfs2021@users.noreply.github.com> Date: Wed, 4 Nov 2026 02:08:43 +0800 Subject: [PATCH] dictBuilder: declare qsort_r on OpenHarmony OpenHarmony (musl) exports qsort_r() with the GNU signature but its headers do not declare it, so stableSort() compiles as an implicit function declaration and fails under -Werror=implicit-function-declaration (OHOS SDK clang 15 defaults). Declare it locally when __OHOS__ is defined so cover.c keeps using the re-entrant GNU variant instead of falling back to the thread-unsafe C90 qsort() path. --- lib/dictBuilder/cover.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/dictBuilder/cover.c b/lib/dictBuilder/cover.c index 06d1cb93a5c..beadeaf14d5 100644 --- a/lib/dictBuilder/cover.c +++ b/lib/dictBuilder/cover.c @@ -39,6 +39,16 @@ #include /* memset */ #include /* clock */ +#if defined(__OHOS__) +/* OpenHarmony (musl) exports qsort_r() with the GNU signature, but its headers + * do not declare it, so the call below would be an implicit declaration. + * Declare it locally to keep using the re-entrant GNU variant. + */ +extern void qsort_r(void *__base, size_t __nmemb, size_t __size, + int (*__compar)(const void *, const void *, void *), + void *__arg); +#endif + #ifndef ZDICT_STATIC_LINKING_ONLY # define ZDICT_STATIC_LINKING_ONLY #endif