Open hsoriot opened 19 hours ago
error: cannot pass object of non-trivial type 'std::basic_string' through variadic function; call will abort at runtime [-Wnon-pod-varargs] int size_s = std::snprintf(nullptr, 0, format_str, args...) + 1; // "\0"
我在make时候遇到了这个错误,gpt解释是snprinf不能接受非平凡类型,args无法提供保证。提供给我的解决方案是把args先转成string再转成const char*。修改后完成了编译 std::ostringstream oss; (oss << ... << args); int size_s = std::snprintf(nullptr, 0, format_str, oss.str().c_str()) + 1; // "\0" 这个编译错误是我的环境引起的吗?
Message that will be displayed on users' first issue
error: cannot pass object of non-trivial type 'std::basic_string' through variadic function; call will abort at runtime [-Wnon-pod-varargs]
int size_s = std::snprintf(nullptr, 0, format_str, args...) + 1; // "\0"
我在make时候遇到了这个错误,gpt解释是snprinf不能接受非平凡类型,args无法提供保证。提供给我的解决方案是把args先转成string再转成const char*。修改后完成了编译 std::ostringstream oss; (oss << ... << args); int size_s = std::snprintf(nullptr, 0, format_str, oss.str().c_str()) + 1; // "\0" 这个编译错误是我的环境引起的吗?