栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

output truncated before terminating nul copying 6 bytes from a string of the same length [-Werror=s

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

output truncated before terminating nul copying 6 bytes from a string of the same length [-Werror=s

在编译某项目代码时出现下面问题,

/data/chw/cnstream6_220/framework/unitest/test_base.cpp: In function ‘std::pair > CreateTempFile(const string&)’:
/data/chw/cnstream6_220/framework/unitest/test_base.cpp:63:10: error: ‘char* strncpy(char*, const char*, size_t)’ output truncated before terminating nul copying 6 bytes from a string of the same length [-Werror=stringop-truncation]
   strncpy(filename + filename_prefix.size(), "XXXXXX", 6);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [framework/unitest/CMakeFiles/cnstream_core_test.dir/build.make:323: framework/unitest/CMakeFiles/cnstream_core_test.dir/test_base.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:261: framework/unitest/CMakeFiles/cnstream_core_test.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

 从错误提示中也能看到,all warnings being treated as errors,所有警告被当成错误了。解决方法是在cmakelists.txt中下面定义,no-stringop-truncation也就是不把这个stringop-truncation当成error了。

add_definitions(-Wno-stringop-truncation)

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/655563.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号