gpt4 book ai didi

c - make—我可以抑制格式截断错误吗?

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

我正在尝试安装 intel's psm package从源头。当我运行 make 时,我得到了这个奇怪的错误。

$ make
...
make libpsm_infinipath.so
make[1]: Entering directory `/home/kilojoules/psm'
cc -Wall -Werror -fpic -fPIC -D_GNU_SOURCE -funwind-tables -O3 -g3 -DNVALGRIND -I. -I/home/kilojoules/psm/include -I/home/kilojoules/psm/mpspawn -I/home/kilojoules/psm/include/linux-x86_64 -c psm_context.c -o psm_context.o
cc -Wall -Werror -fpic -fPIC -D_GNU_SOURCE -funwind-tables -O3 -g3 -DNVALGRIND -I. -I/home/kilojoules/psm/include -I/home/kilojoules/psm/mpspawn -I/home/kilojoules/psm/include/linux-x86_64 -c psm_ep.c -o psm_ep.o
psm_ep.c: In function '__psm_ep_open':
psm_ep.c:1013:27: error: '%1d' directive output may be truncated writing between 1 and 5 bytes into a region of size 4 [-Werror=format-truncation=]
snprintf(pvalue, 4, "%1d", ports[0]);
^~~
psm_ep.c:1013:26: note: directive argument in the range [0, 65535]
snprintf(pvalue, 4, "%1d", ports[0]);
^~~~~
psm_ep.c:1013:6: note: 'snprintf' output between 2 and 6 bytes into a destination of size 4
snprintf(pvalue, 4, "%1d", ports[0]);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
psm_ep.c:1041:27: error: '%1d' directive output may be truncated writing between 1 and 5 bytes into a region of size 4 [-Werror=format-truncation=]
snprintf(pvalue, 4, "%1d", ports[i]);
^~~
psm_ep.c:1041:26: note: directive argument in the range [0, 65535]
snprintf(pvalue, 4, "%1d", ports[i]);
^~~~~
psm_ep.c:1041:6: note: 'snprintf' output between 2 and 6 bytes into a destination of size 4
snprintf(pvalue, 4, "%1d", ports[i]);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [psm_ep.o] Error 1
make: *** [libs] Error 2

我想抑制错误。看起来这是一个警告而不是一个错误。那是我可以在这里做的事吗?我该怎么做?

最佳答案

由于 -Werror 标志被传递给编译器,因此将其视为错误。该标志告诉编译器将任何警告转换为错误(参见 cc1: all warnings being treated as errors)输出行。删除该标志以更改行为(您可能必须编辑 makefile)。

关于c - make—我可以抑制格式截断错误吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51119880/

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