使用 make 命令构建项目时出错,使用了未声明的标识符“__compar_fn_t”
Error building project with make command, use of undeclared identifier '__compar_fn_t'
我正在尝试构建 RedisBloom 并在 运行 make 命令后出现以下错误。
clang -dynamic -fcommon -g -ggdb -Wall -Wno-unused-function -g -ggdb -O2 -fPIC -std=gnu99 -D_GNU_SOURCE -I/Users/john/workspace/RedisBloom/contrib -I/Users/john/workspace/RedisBloom -I/Users/john/workspace/RedisBloom/src -I/Users/john/workspace/RedisBloom/deps/t-digest-c/src -c -o /Users/john/workspace/RedisBloom/src/topk.o /Users/john/workspace/RedisBloom/src/topk.c
/Users/john/workspace/RedisBloom/src/topk.c:223:50: error: use of undeclared identifier '__compar_fn_t'
qsort(heapList, topk->k, sizeof(*heapList), (__compar_fn_t)cmpHeapBucket);
^
1 error generated.
make: *** [/Users/dsesma/eclipse-workspace/RedisBloom/src/topk.o] Error 1
我正在使用 macOS Big Sur
RedisBloom 项目使用实现细节 (__compar_fn_t
) 将 cmpHeapBucket
的函数签名从快捷签名转换为正确的签名。依赖这样的实现细节是不好的,而且往往不是很便携。
我建议您下载最新版本的RedisBloom。我对其进行了 a patch,现在已合并到 master
,它执行以下操作:
在 src/topk.c
中修复:
// make the compare function have the correct signature:
int cmpHeapBucket(const void *tmp1, const void *tmp2) {
const HeapBucket *res1 = tmp1;
const HeapBucket *res2 = tmp2;
return res1->count < res2->count ? 1 : res1->count > res2->count ? -1 : 0;
}
HeapBucket *TopK_List(TopK *topk) {
HeapBucket *heapList = TOPK_CALLOC(topk->k, (sizeof(*heapList)));
memcpy(heapList, topk->heap, topk->k * sizeof(HeapBucket));
// now, no cast is needed below:
qsort(heapList, topk->k, sizeof(*heapList), cmpHeapBucket);
return heapList;
}
我正在尝试构建 RedisBloom 并在 运行 make 命令后出现以下错误。
clang -dynamic -fcommon -g -ggdb -Wall -Wno-unused-function -g -ggdb -O2 -fPIC -std=gnu99 -D_GNU_SOURCE -I/Users/john/workspace/RedisBloom/contrib -I/Users/john/workspace/RedisBloom -I/Users/john/workspace/RedisBloom/src -I/Users/john/workspace/RedisBloom/deps/t-digest-c/src -c -o /Users/john/workspace/RedisBloom/src/topk.o /Users/john/workspace/RedisBloom/src/topk.c
/Users/john/workspace/RedisBloom/src/topk.c:223:50: error: use of undeclared identifier '__compar_fn_t'
qsort(heapList, topk->k, sizeof(*heapList), (__compar_fn_t)cmpHeapBucket);
^
1 error generated.
make: *** [/Users/dsesma/eclipse-workspace/RedisBloom/src/topk.o] Error 1
我正在使用 macOS Big Sur
RedisBloom 项目使用实现细节 (__compar_fn_t
) 将 cmpHeapBucket
的函数签名从快捷签名转换为正确的签名。依赖这样的实现细节是不好的,而且往往不是很便携。
我建议您下载最新版本的RedisBloom。我对其进行了 a patch,现在已合并到 master
,它执行以下操作:
在 src/topk.c
中修复:
// make the compare function have the correct signature:
int cmpHeapBucket(const void *tmp1, const void *tmp2) {
const HeapBucket *res1 = tmp1;
const HeapBucket *res2 = tmp2;
return res1->count < res2->count ? 1 : res1->count > res2->count ? -1 : 0;
}
HeapBucket *TopK_List(TopK *topk) {
HeapBucket *heapList = TOPK_CALLOC(topk->k, (sizeof(*heapList)));
memcpy(heapList, topk->heap, topk->k * sizeof(HeapBucket));
// now, no cast is needed below:
qsort(heapList, topk->k, sizeof(*heapList), cmpHeapBucket);
return heapList;
}