void CLogDemonImpl::sendLog(const EN_MMS_LOG_LEVEL logLevel,
const EN_MMS_LOG_TYPE logType,
const EN_MMS_LOG_ACTION logAction,
const char* pFile,
const MMS_UINT32 nLine,
const char* Module,
const char* lpszBasicInfo,
const char* lpszFormat,
...)
从红色部分可以看出,sendLog使用了可变参数的特性。编译器无法在编译时刻了解函数需要的参数是什么类型,因而无法进行类型的检查!
在使用可变参数时,对传入的实参是不是有什么要求呢?
使用gcc编译器,对上述有问题的代码会产生如下的告警信息:
/home/syb/mms_home/source/csrc/server/srvmmmanager.cpp: In member function `
void CSrvMMManager::EnableFRSession(CSrvSessWrapper&, bool, CMMMsg**)':
/home/syb/mms_home/source/csrc/server/srvmmmanager.cpp:4494: warning: cannot
pass objects of non-POD type `struct SString' through `...'; call will abort
at runtime
/home/syb/mms_home/source/csrc/server/srvmmmanager.cpp:4494: warning: cannot
pass objects of non-POD type `const struct SString' through `...'; call will
abort at runtime
/home/syb/mms_home/source/csrc/server/srvmmmanager.cpp:4494: warning: cannot
pass objects of non-POD type `struct SString' through `...'; call will abort
at runtime
/home/syb/mms_home/source/csrc/server/srvmmmanager.cpp:4494: warning: cannot
pass objects of non-POD type `const struct SString' through `...'; call will
abort at runtime
阅读(644) | 评论(0) | 转发(0) |