当我下载FNV 5.0.3并在Mac上构建它时,我收到了许多关于格式字符串中的转换规范与实际传递的参数不匹配的编译器警告。然而,当我跑步时
make check
,代码报告测试向量全部通过。(它使用
echo -n
但是
echo
我不认识
-n
作为选项,因此输出看起来有点奇怪。)
生成输出示例:
$ make
forming longlong.h
longlong.h formed
cc -O3 -g3 hash_32.c -c
cc -O3 -g3 hash_64.c -c
cc -O3 -g3 hash_32a.c -c
cc -O3 -g3 hash_64a.c -c
cc -O3 -g3 test_fnv.c -c
test_fnv.c:2183:5: warning: implicitly declaring library function 'exit' with type 'void (int)
__attribute__((noreturn))'
exit(code);
^
test_fnv.c:2183:5: note: please include the header <stdlib.h> or explicitly provide a declaration
for 'exit'
test_fnv.c:2200:25: warning: format specifies type 'unsigned long' but the argument has type
'unsigned int' [-Wformat]
printf("0x%08lx %s\n", hval & mask, arg);
~~~~~ ^~~~~~~~~~~
%08x
test_fnv.c:2202:22: warning: format specifies type 'unsigned long' but the argument has type
'unsigned int' [-Wformat]
printf("0x%08lx\n", hval & mask);
~~~~~ ^~~~~~~~~~~
%08x
3 warnings generated.
rm -f libfnv.a
ar rv libfnv.a hash_32.o hash_64.o hash_32a.o hash_64a.o test_fnv.o
ar: creating archive libfnv.a
a - hash_32.o
a - hash_64.o
a - hash_32a.o
a - hash_64a.o
a - test_fnv.o
: libfnv.a
cc -O3 -g3 fnv32.c -c
fnv32.c:156:21: warning: format specifies type 'unsigned long' but the argument has type
'unsigned int' [-Wformat]
tstnum-1, hval & mask);
^~~~~~~~~~~
fnv32.c:168:17: warning: format specifies type 'unsigned long' but the argument has type
'unsigned int' [-Wformat]
program, (hval&mask),
^~~~~~~~~~~
fnv32.c:169:8: warning: format specifies type 'unsigned long' but the argument has type
'unsigned int' [-Wformat]
(fnv0_32_vector[tstnum-1].fnv0_32 & mask));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fnv32.c:182:17: warning: format specifies type 'unsigned long' but the argument has type
'unsigned int' [-Wformat]
program, (hval&mask),
^~~~~~~~~~~
fnv32.c:183:8: warning: format specifies type 'unsigned long' but the argument has type
'unsigned int' [-Wformat]
(fnv1_32_vector[tstnum-1].fnv1_32 & mask));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fnv32.c:196:17: warning: format specifies type 'unsigned long' but the argument has type
'unsigned int' [-Wformat]
program, (hval&mask),
^~~~~~~~~~~
fnv32.c:197:8: warning: format specifies type 'unsigned long' but the argument has type
'unsigned int' [-Wformat]
(fnv1a_32_vector[tstnum-1].fnv1a_32 & mask));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fnv32.c:159:14: warning: 4 enumeration values not handled in switch: 'FNV_NONE', 'FNV0_64',
'FNV1_64'... [-Wswitch]
switch (hash_type) {
^
8 warnings generated.
cc fnv32.o libfnv.a -o fnv032
cc -O3 -g3 fnv64.c -c
fnv64.c:164:14: warning: 4 enumeration values not handled in switch: 'FNV_NONE', 'FNV0_32',
'FNV1_32'... [-Wswitch]
switch (hash_type) {
^
1 warning generated.
cc fnv64.o libfnv.a -o fnv064
rm -f fnv132
cp -f fnv032 fnv132
rm -f fnv164
cp -f fnv064 fnv164
rm -f fnv1a32
cp -f fnv032 fnv1a32
rm -f fnv1a64
cp -f fnv064 fnv1a64
$
跑步
核对,核对
:
$ make check
-n FNV-0 32 bit tests:
passed
-n FNV-1 32 bit tests:
passed
-n FNV-1a 32 bit tests:
passed
-n FNV-0 64 bit tests:
passed
-n FNV-1 64 bit tests:
passed
-n FNV-1a 64 bit tests:
passed
$
警告并不理想。如果我精力充沛,我可能会制作补丁并将其提交给FNV网站。这取决于当我使用更严格的编译选项运行时得到的选择。
您的主要问题已解决
然而,您当前的问题是
test_fnv.c
并非设计为自行编译成程序;它是图书馆的一部分。