有些人在使用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
答案 0 :(得分:0)
这是printf的标准警告。好的开始是:
man 3 printf
基本上解决方案就是:
std::size_t a0 = 1234;
printf("%zu\n", a0);
而不是:
std::size_t a0 = 1234;
printf("%d\n", a0);
答案 1 :(得分:0)
您在此处定义的断言宏:
#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
使用"%d"
中用于整数的fprintf
格式字符串。
但是你将宏用于在这里返回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
方法的结果转换为有符号整数(如果您知道很可能没有溢出问题)。