赞
踩
在编译某项目代码时出现下面问题,
- /data/chw/cnstream6_220/framework/unitest/test_base.cpp: In function ‘std::pair<int, std::__cxx11::basic_string<char> > 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)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。