当前位置:   article > 正文

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

output truncated before terminating nul copying 6 bytes from a string of the

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

  1. /data/chw/cnstream6_220/framework/unitest/test_base.cpp: In function ‘std::pair<int, std::__cxx11::basic_string<char> > CreateTempFile(const string&)’:
  2. /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]
  3. strncpy(filename + filename_prefix.size(), "XXXXXX", 6);
  4. ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5. cc1plus: all warnings being treated as errors
  6. 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
  7. make[1]: *** [CMakeFiles/Makefile2:261: framework/unitest/CMakeFiles/cnstream_core_test.dir/all] Error 2
  8. 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)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/在线问答5/article/detail/810517
推荐阅读
相关标签
  

闽ICP备14008679号