错误:无法传递非平凡类型"std::string"的对象和更多错误
error: cannot pass object of non-trivial type 'std::string' and more errors
我正在Travis CI中运行构建,在编译过程中,发生了此错误。我尝试指定C++编译器并尝试使用 g++,但这导致了更多错误。
$ clang -I ./jsoncpp/include/ -L ./jsoncpp/build/debug/lib -std=c++14 -v test.cpp -o buildtest.exe
...
./IBMWatson.h:79:44: error: cannot pass object of non-trivial type 'std::string'
(aka 'basic_string<char>') through variadic function; call will abort at
runtime [-Wnon-pod-varargs]
curl_easy_setopt(curl, CURLOPT_PASSWORD, apikey); /* Par...
^
./IBMWatson.h:81:39: error: cannot pass object of non-trivial type 'std::string'
(aka 'basic_string<char>') through variadic function; call will abort at
runtime [-Wnon-pod-varargs]
curl_easy_setopt(curl, CURLOPT_URL, url); /* Sets Regio...
^
./IBMWatson.h:104:102: warning: result of comparison against a string literal is
unspecified (use strncmp instead) [-Wstring-compare]
...+ response.length(), &root, &err) || funcName == "returnVoices" || funcN...
...
4 warnings and 4 errors generated.
The command "clang -I ./jsoncpp/include/ -L ./jsoncpp/build/debug/lib -std=c++14 -v test.cpp -o buildtest.exe" exited with 1.
>curl_easy_setopt
是一个C函数,其中可变参数实际上表示<cstdarg>
的...
参数。它只接受平凡的类型,而std::string
不是(即,它不能用memcpy
复制,而是涉及一个非平凡的复制构造函数(;否则,行为是未定义的或仅有条件地支持。为了传递字符串值,请使用其const char*
表示形式,c_str()
curl_easy_setopt(curl, CURLOPT_PASSWORD, apikey.c_str());
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
相关文章:
- C++:如何将 unix 时间的字符串转换为 *tm?(使用时间错误:"cannot convert 'String' to 'tm*' ")
- 为什么当我在 std::string 中打开文件名的 fstream 时出现"no matching function"错误?
- 错误消息:使用"string* +="后"no match for 'operator+='"
- 将图形表示为unordered_map<字符串、向量>时拓扑排序错误<string>
- OpenCV 3.4.3 中对 'cv::String::d eallocate()' 错误的未定义引用
- 错误:无法传递非平凡类型"std::string"的对象和更多错误
- 由于矢量引起的错误<string>?
- 错误:调用"es_queue::set_rpc_vector(std::vector >&, std::__cxx11::string)"没有匹配函数
- 错误:"cast"未命名类型void setCastDescription(std::string
- 错误:为"运算符 std::string {aka std::__cxx11::basic_string}"指定的返回类型<char>
- 为什么 std::atomic<std::string> 会给出微不足道的可复制错误?
- pip install uwsgi 失败,出现 /usr/local/include/string/string.h:7:10:致命错误:找不到'sstream'文件?
- 如果子类中没有构造函数方法,则错误"no matching function for call to 'LGame::LGame(String&)'"
- 使用 string::p op_back() 的编译错误
- 错误:请求从"Mstream"转换为非标量类型"std::string {aka std::basic_string<char>}"
- 编译错误"String does not name a type"
- ODBC 错误"String data, right truncation State code: 22001"与 SQL Server 数据库
- 错误"String subscript out of range"
- C2059 语法错误 'string' ?
- c++错误:' string '没有指定类型