pclint 测试时遇到的error1058 求高手帮忙解决~~~~~~~~~~~~

C、C++和Java语言
回复
jili_baoer
帖子: 11
注册时间: 2007-08-04 10:04
送出感谢: 0
接收感谢: 0

pclint 测试时遇到的error1058 求高手帮忙解决~~~~~~~~~~~~

#1

帖子 jili_baoer » 2007-08-09 11:23

int CApiNet::GetValueAndStatus(const std::vector<struct KEY_ID_STRU> &struVec , std::vector< struct CHAR_VALUE_STATUS > & KeyIdValVec) //yx
{
int ret_code = DB_OK;

try
{
ret_code = Refresh();
if( ret_code < DB_OK )
{
TRACE("fail to get service host, errno = %d\n", ret_code);
return ret_code;
}

CODB_NET::REQ_BASE base_info;
base_info.context_no = m_ContextNo;
base_info.app_no = m_AppNo;
base_info.table_no = m_TableNo;
base_info.byte_tag = m_ByteTag;

CODB_NET::REQ_VAL_STA req_key_id;
req_key_id.base_info = base_info;
req_key_id.req_type = 3; //yx

req_key_id.keyid_sta_stru_seq.length(0);
req_key_id.keyid_stru_seq.length(struVec.size());

for(int i = 0; i < req_key_id.keyid_stru_seq.length(); i++)
{
req_key_id.keyid_stru_seq.record_id = struVec.record_id;
req_key_id.keyid_stru_seq.column_id = struVec.column_id;
}

ODB_CORBA::CODB_NET::RSP_INT_VAL_STA_var rsp_int_val;
ODB_CORBA::CODB_NET::RSP_FLOAT_VAL_STA_var rsp_float_val;
ODB_CORBA::CODB_NET::RSP_CHAR_VAL_STA_var rsp_char_val;
ODB_CORBA::CODB_NET::RSP_UNION_VAL_STA_var rsp_union_val;

ret_code = m_OdbNet->GetValueAndStatus(req_key_id , rsp_int_val , rsp_float_val , rsp_char_val , rsp_union_val); //此行报错。
//错误的提示:
ret_code = m_OdbNet->GetValueAndStatus(req_key_id , rsp_int_val , rsp_float_val , rsp_char_val , rsp_union_val);
odb_lidb_apinet.cpp(3048): error 1058: (Error -- Initializing a non-const reference 'OB::VarVar<RSP_INT_VAL_STA> &' with a non-lvalue)
odb_apinet.cpp(3048): error 1058: (Error -- Initializing a non-const reference 'OB::VarVar<RSP_FLOAT_VAL_STA> &' with a non-lvalue)
odb_apinet.cpp(3048): error 1058: (Error -- Initializing a non-const reference 'OB::VarVar<RSP_CHAR_VAL_STA> &' with a non-lvalue)
odb_apinet.cpp(3048): error 1058: (Error -- Initializing a non-const reference 'OB::VarVar<RSP_UNION_VAL_STA> &' with a non-lvalue)
头像
antonym55
帖子: 353
注册时间: 2007-04-03 9:52
送出感谢: 0
接收感谢: 0
联系:

#2

帖子 antonym55 » 2007-08-09 20:33

1058 Initializing a non-const reference 'Symbol' with a non-lvalue --

A reference is normally initialized with an lvalue. If you

attempt to initialize a reference with a non-lvalue, a temporary

is created to serve as a surrogate lvalue. However,

modifications made to the temporary will be lost. This was legal

at one time and is now illegal. Make the reference a const if

you can.
You may be initializing a reference without realizing

it. A member function has an implicit parameter which is taken

to be a reference to its object. If this is the situation make

the member const. That is, use void f(...) const; rather than

void f(...);
TODO LIST:
1.valgrind:
2.gcov:
3.cppuint:未在Linux中使用
4.PostgreSQL:unixODBC
5.Doxygen:UTF8 中文问题,生成LaTex文档问题
6.LaTex:明确安装问题,UTF8 中文字体问题
回复

回到 “C/C++/Java”