VS2003中ACE_Asynch_Acceptor打开失败
在默认的VS2003环境下,以下代码会运行失败;因为在VS2003属性->属性配置->C/C++->语言->启动运行时类型信息(这里默认为否);将该项值设为是,即可; 而在VS2005中, 默认为是。
#include "ace/OS_main.h"
#include "ace/Service_Config.h"
#include "ace/Proactor.h"
#include "ace/Asynch_IO.h"
#include "ace/Asynch_IO_Impl.h"
#include "ace/Asynch_Acceptor.h"
#include "ace/INET_Addr.h"
#include "ace/SOCK_Connector.h"
#include "ace/SOCK_Acceptor.h"
#include "ace/WIN32_Proactor.h"
class Receiver : public ACE_Service_Handler
{
};
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
ACE::init();
ACE_Asynch_Acceptor<Receiver> acceptor;
ACE_WIN32_Proactor* pWin32Proactor = new ACE_WIN32_Proactor(4);
ACE_Proactor* p = new ACE_Proactor(pWin32Proactor,1,0);
int ret=acceptor.open(ACE_INET_Addr (7114), 0, 1, ACE_DEFAULT_ASYNCH_BACKLOG, 1, p);//会在这里出错.
delete p;
p = NULL;
ACE::fini();
return 0;
}
不打开在编译的时候估计应该会有个警告,说你没有打开而又用了dynamic cast
页:
[1]