[omniORB] Fw: (by abcluo@163.com)
use sequence<struct> problem ?
roger
abcluo at 163.com
Mon Oct 23 14:39:11 BST 2006
Hi,
My problem was Solved!
Thanks to everyone!
Special thanks Clarke Brunt!
I am use omniORB4.0.7 on win2000+vc7.1,
The problem isn't Cause by use sequence<struct> ,and it is caused by project setting lib file and runtime library mode!
The project setting choose "Multithreaded DLL(release build)" or "Debug Multithreaded DLL (debug build)". This is OK.
My application is work fine now!
Application code :
=====================================
//----------IDL---------
struct NetDataItem
{
long id;
string name;
};
typedef sequence<NetDataItem> DataArray;
typedef sequence<long> DataLongArray;
interface QDataSeq
{
DataArray QueryDatas();
DataLongArray QueryLongData();
};
//---------server code--------------
// return struct data Sequence
DataArray* QDataSeq_i::QueryDatas(){
int cnt =100;
DataArray_var datas = new DataArray((CORBA::Long)cnt);
datas->length(cnt);
for (int i =0;i< cnt; ++i)
{
datas[i].id = (CORBA::Long)(i+1);
datas[i].name = CORBA::string_dup("aaaa"); //
}
std::cout << "OK" << endl;
return datas._retn();
}
// return long Sequence
DataArray* QDataSeq_i::QueryLongData(){
int cnt =100;
DataLongArray_var datas = new DataLongArray((CORBA::Long)cnt);
datas->length(cnt);
for (int i =0;i< cnt; ++i)
{
datas[i] = (CORBA::Long)(i+1);
}
std::cout << "OK" << endl;
return datas._retn();
}
//-----------client code-----------------------
//query struct data Sequence , use _var
void queryStructSeqData(QDataSeq_ptr e)
{
DataArray_var dest = e->QuearyDatas();
int len = pdest->length();
std::cerr << "query sequence size £º" << len << endl;
//do something...
}
//query long Sequence. It is work fine and not have memory leak.
void queryLongSeqData(QDataSeq_ptr e)
{
DataArray_var dest = e->QueryLongData();
int len = dest->length();
std::cerr << "query sequence size is:" << len << endl;
//do something...
}
//-----------project setting--------------
debug mode add The following Libraries to "Additional Dependencies":
omniORB407_rtd.lib
omnithread32_rtd.lib
omniDynamic407_rtd.lib
ws2_32.lib
mswsock.lib
odbc32.lib
odbccp32.lib
Run-time library:Debug Multithreaded DLL
----------------
release mode add The following Libraries to "Additional Dependencies":
omniORB407_rt.lib
omnithread32_rt.lib
omniDynamic407_rt.lib
ws2_32.lib
mswsock.lib
odbc32.lib
odbccp32.lib
Run-time library:Multithreaded DLL
====================================
Thanks again to everyone!
-----ÔʼÓʼþ-----
·¢¼þÈË:"Clarke Brunt"
·¢ËÍʱ¼ä:2006-10-18 00:33:38
ÊÕ¼þÈË:""
³ËÍ:(ÎÞ)
Ö÷Ìâ:Re: [omniORB] Fw: (by abcluo at 163.com)use sequ ence problem ?
I still mainly use VC6 myself, so can't be sure option options in 7.
In VC6, under Project Settings, C/C++, Code Generation, Use run-time
library, you need to choose Multithreaded DLL (or Debug Multithreaded
DLL for debug build), and not either of the single threaded options, or
the ones which don't mention DLL (statically linked). I would guess that
VC7 has similar options?
--
Clarke Brunt, Principal Software Engineer, Trafficmaster
This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.
_______________________________________________
omniORB-list mailing list
omniORB-list at omniorb-support.com
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20061023/74bcfadb/attachment.htm
More information about the omniORB-list
mailing list