PLCXProcess.cpp:5188:27: error: no matching function for call to 'XJUtilClass::XJTxtLog::info(std::string&)' pLogger->info(strlog_db); ^ PLCXProcess.cpp:5188:27: note: candidate is: In file included from /app/smsprev4/lib/Transaction9308/Transaction.h:13:0, from /app/smsprev4/lib/Transaction9308/Transaction9308.h:10, from PLCXProcess.h:39, from PLCXProcess.cpp:9: /app/smsprev4/lib/Transaction9308/XJTxtLog.h:80:6: note: int XJUtilClass::XJTxtLog::info(const char*, ...) int info(const char* szFormat, ...);strlog_db = "Exception thrown for delete t_pkk_fail"; pLogger->info(strlog_db); strlog_db = "Error Msg:"; strlog_db += ex.getMessage(); pLogger->info(strlog_db);
时间: 2024-04-06 07:32:38 浏览: 10
这是一个编译错误,提示在 PLCXProcess.cpp 文件的第 5188 行出现了一个不匹配的函数调用。XJUtilClass::XJTxtLog 类的 info 函数需要传入一个 const char* 类型的参数,但是传入了一个 std::string& 类型的参数。建议将 strlog_db 参数改为 const char* 类型,或者使用 c_str() 函数将 std::string 类型的参数转换为 const char* 类型。
相关问题
PLCXProcess.cpp: In member function 'int CPLCXProcess::tradewithxhx(oracle::occi::Connection*, std::string, std::string, std::string, std::string&, std::string&)': PLCXProcess.cpp:4196:63: error: no matching function for call to 'CPLCXProcess::getLvkaStat
根据你的问题,我猜测你遇到了编译错误。这个错误的意思是在 `CPLCXProcess` 类的 `tradewithxhx` 成员函数中,调用了一个名为 `getLvkaStat` 的函数,但是编译器找不到这个函数的匹配项。
有几种可能的原因导致这个错误:
1. `getLvkaStat` 函数没有被定义:请检查你的代码,确保在 `CPLCXProcess` 类的定义中有 `getLvkaStat` 函数的实现。
2. `getLvkaStat` 函数的参数不匹配:请检查你调用 `getLvkaStat` 函数的代码,确保传递给函数的参数类型和数量与函数定义中的参数类型和数量匹配。
3. `getLvkaStat` 函数在 `CPLCXProcess` 类的定义之外定义了:如果 `getLvkaStat` 函数不是 `CPLCXProcess` 类的成员函数,那么你需要在调用它的代码中提供正确的命名空间或者包含相应的头文件。
希望这些提示能够帮助你找到问题所在。
PLCXProcess.cpp: In member function 'int CPLCXProcess::INSERTCXDATA(oracle::occi::Connection*, std::vector<PCXPackage>, long int&, std::string)': PLCXProcess.cpp:1042:30: error: no matching function for call to 'CPLCXProcess::GetCurLocalDate(std::string&)' GetCurLocalDate(strLocalDate); ^ PLCXProcess.cpp:1042:30: note: candidate is: In file included from PLCXProcess.cpp:9:0:
这是一个编译错误,错误信息显示在调用 `GetCurLocalDate` 函数时传递了一个错误的参数类型。
在C++中,参数类型非常重要。函数的参数类型必须与函数声明中的参数类型完全匹配。在这种情况下,`GetCurLocalDate` 函数声明的参数类型是 `char*`,而实际传递的参数类型是 `std::string`,它们不匹配。
解决方法:
有两种解决方法:
1. 将 `GetCurLocalDate` 函数的参数类型改为 `std::string`,例如:
```
void GetCurLocalDate(std::string& szLocalDate);
```
然后在函数实现中,将日期字符串赋值给 `szLocalDate`。这样就可以使用 `std::string` 类型的参数调用函数了。
2. 将 `std::string` 转换为 `char*` 类型,例如:
```
std::string strLocalDate = "2022-01-01";
char* szLocalDate = new char[strLocalDate.size() + 1];
std::strcpy(szLocalDate, strLocalDate.c_str());
GetCurLocalDate(szLocalDate);
delete[] szLocalDate;
```
在这种情况下,我们先创建一个指向字符数组的指针 `szLocalDate`,然后使用 `strcpy` 函数将 `std::string` 类型的字符串复制到字符数组中。最后,我们将指向字符数组的指针作为参数传递给 `GetCurLocalDate` 函数。注意,在使用完字符数组后,需要使用 `delete` 关键字释放内存,以免造成内存泄漏。