gpt4 book ai didi

c++ - benderrmq 出错

转载 作者:太空宇宙 更新时间:2023-11-04 03:54:24 25 4
gpt4 key购买 nike

有些人在使用 make 命令进行编译时遇到了问题,所以我想我应该在这里尝试一下,我已经在以下操作系统的 ubuntu 32 位和挤压 64 位上尝试过

我克隆了 git 项目 https://github.com/duckduckgo/cpp-libface/运行 make 命令,我不断收到以下信息

    g++ -o lib-face src/main.cpp src/httpserver.o deps/libuv/libuv.a deps/http-parser/http_parser.o -I . -I deps -Wall  -D_FILE_OFFSET_BITS=64 -O2 -lm -lrt -pthread
In file included from src/main.cpp:21:
./include/benderrmq.hpp: In member function 'uint_t LookupTables::query_max(uint_t, uint_t, uint_t)':
./include/benderrmq.hpp:250: warning: format '%d' expects type 'int', but argument 4 has type 'size_t'
./include/benderrmq.hpp:251: warning: format '%d' expects type 'int', but argument 4 has type 'size_t'
./include/benderrmq.hpp:252: warning: format '%d' expects type 'int', but argument 4 has type 'size_t'
./include/benderrmq.hpp: In member function 'void BenderRMQ::initialize(const vui_t&)':
./include/benderrmq.hpp:353: warning: format '%d' expects type 'int', but argument 3 has type 'size_t'
./include/benderrmq.hpp:353: warning: format '%d' expects type 'int', but argument 4 has type 'size_t'
./include/benderrmq.hpp:354: warning: format '%d' expects type 'int', but argument 3 has type 'size_t'
./include/benderrmq.hpp:354: warning: format '%d' expects type 'int', but argument 4 has type 'size_t'

日志比较长,但把重要的部分拉出来

有错误的文件位于 https://raw.githubusercontent.com/duckduckgo/cpp-libface/master/include/benderrmq.hpp

最佳答案

此处定义的断言宏:

#define assert_lt(X,Y) if (!((X)<(Y))) { fprintf(stderr, "%d < %d FAILED\n", (X), (Y)); assert((X)<(Y)); }
#define assert_gt(X,Y) if (!((X)>(Y))) { fprintf(stderr, "%d > %d FAILED\n", (X), (Y)); assert((X)>(Y)); }
#define assert_le(X,Y) if (!((X)<=(Y))) { fprintf(stderr, "%d <= %d FAILED\n", (X), (Y)); assert((X)<=(Y)); }
#define assert_eq(X,Y) if (!((X)==(Y))) { fprintf(stderr, "%d == %d FAILED\n", (X), (Y)); assert((X)==(Y)); }
#define assert_ne(X,Y) if (!((X)!=(Y))) { fprintf(stderr, "%d != %d FAILED\n", (X), (Y)); assert((X)!=(Y)); }

https://github.com/duckduckgo/cpp-libface/blob/master/include/utils.hpp

fprintf 中使用用于整数的 "%d" 格式字符串。

但是您将宏与返回 size_t 的方法一起使用:

assert_lt(index, repr.size());
assert_lt(l, repr[0].size() + 1);
assert_lt(u, repr[0][0].size());

这里:

assert_eq(levels.size(), euler.size());
assert_eq(levels.size(), rev_mapping.size());

https://github.com/duckduckgo/cpp-libface/blob/master/include/benderrmq.hpp

因此,您可以创建其他使用 "%zu" 的宏,或者将 size 方法的结果转换为有符号整数(如果您知道很可能不会出现溢出问题)。

关于c++ - benderrmq 出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25241227/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com