在编译某项目代码时出现下面问题,
/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)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)