陈学峰: int info(const char* szFormat, ...); 陈学峰: 多个参数 陈学峰: pLogger->info("%s",strlog_db.cstr());
时间: 2024-04-06 14:32:59 浏览: 18
这行代码中,`pLogger` 可能是一个指向日志记录器的指针,它调用了 `info` 函数,并传递了两个参数:第一个参数是一个格式化字符串,其中 `%s` 表示后面跟的参数是一个字符串;第二个参数 `strlog_db.cstr()` 是一个字符串对象的成员函数,返回一个以 null 结尾的 C 风格字符串,作为 `info` 函数的可变参数之一。这样,`info` 函数可能会将这个字符串记录在日志文件或控制台上。
相关问题
from PLCXProcess.cpp:9: /app/smsprev4/lib/Transaction9308/XJTxtLog.h:80:6: note: int XJUtilClass::XJTxtLog::info(const char*, ...) int info(const char* szFormat, ...); ^ /app/smsprev4/lib/Transaction9308/XJTxtLog.h:80:6: note: no known conversion for argument 1 from 'std::string {aka std::basic_string<char>}' to 'const char*' PLCXProcess.cpp:5188:27: error: no matching function for call to 'XJUtilClass::XJTxtLog::info(std::string&)' pLogger->info(strlog_db);
这个错误的原因是XJTxtLog::info()函数的参数是const char*类型的,而你传入了一个std::string类型的参数。你需要将std::string类型的参数转换成const char*类型的参数,可以使用c_str()函数来完成这个转换,例如:
pLogger->info(strlog_db.c_str());
LCXProcess.cpp:5095: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, ...); ^
这是一个编译错误信息,其中给出了一个函数的候选项。这个函数是在XJTxtLog.h文件中定义的,名为XJUtilClass::XJTxtLog::info,它返回一个整数,并接受一个const char*类型的参数szFormat和可变数量的参数(...)。这个函数可能被用于在应用程序日志中记录信息。
相关推荐
![cpp](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)