报上你的config.h看看吧。
回复 #11 winston 的帖子
config.h#define ACE_HAS_STANDARD_CPP_LIBRARY 1
#include "ace/config-win32.h" config-win32.h
/* -*- C++ -*- */
//=============================================================================
/**
*@file config-win32.h
*
*config-win32.h,v 4.68 2005/10/06 22:15:50 shuston Exp
*
*@briefMicrosoft Windows configuration file.
*
*This file is the ACE configuration file for all of Microsoft Windows
*platforms that ACE runs on.Based on preprocessor definitions, it
*includes other more specific configuration files.
*
*@author Darrell Brunsch <brunsch@cs.wustl.edu>
*/
//=============================================================================
#ifndef ACE_CONFIG_WIN32_H
#define ACE_CONFIG_WIN32_H
#include /**/ "ace/pre.h"
// NOTE: Please do not add anything besides #include's here.Put other stuff
// (definitions, etc.) in the included headers
// We need to ensure that for Borland vcl.h can be included before
// windows.h.So we will not include config-win32-common.h from here,
// but instead let it be included at the appropriate place in
// config-win32-borland.h.
#if !defined (__BORLANDC__)
# include "ace/config-win32-common.h"
#endif /* !__BORLANDC__ */
// Include the config-win32-* file specific to the compiler
#if defined (__BORLANDC__)
# include "ace/config-win32-borland.h"
#elif defined (_MSC_VER)
# include "ace/config-win32-msvc.h"
#elif defined (__IBMCPP__)
# include "ace/config-win32-visualage.h"
#elif defined (ghs)
# include "ace/config-win32-ghs.h"
#elif defined (__MINGW32__)
# include "ace/config-win32-mingw.h"
#elif defined (__DMC__)
# include "ace/config-win32-dmc.h"
#else
# error Compiler is not supported
#endif
#include /**/ "ace/post.h"
#endif /* ACE_CONFIG_WIN32_H */ config-win32-msvc.h
//=============================================================================
/**
*@file config-win32-msvc.h
*
*config-win32-msvc.h,v 4.31 2005/10/06 22:15:50 shuston Exp
*
*@briefMicrosoft Visual C++ configuration file.
*
*This file is the ACE configuration file for Microsoft Visual C++ versions
*5.0, 6.0, and 7.0 (.NET)
*
*@author Darrell Brunsch <brunsch@cs.wustl.edu>
*/
//=============================================================================
#ifndef ACE_CONFIG_WIN32_MSVC_H
#define ACE_CONFIG_WIN32_MSVC_H
#include /**/ "ace/pre.h"
#ifndef ACE_CONFIG_WIN32_H
#error Use config-win32.h in config.h instead of this header
#endif /* ACE_CONFIG_WIN32_H */
#define ACE_CC_NAME ACE_LIB_TEXT ("Visual C++")
#define ACE_CC_PREPROCESSOR "CL.EXE"
#define ACE_CC_PREPROCESSOR_ARGS "-nologo -E"
#define ACE_CC_MAJOR_VERSION (_MSC_VER / 100 - 6)
#define ACE_CC_MINOR_VERSION (_MSC_VER % 100)
#define ACE_CC_BETA_VERSION (0)
#if !defined (ACE_LD_DECORATOR_STR)
# if defined (_DEBUG)
#if ACE_HAS_MFC == 1
# define ACE_LD_DECORATOR_STR ACE_LIB_TEXT ("mfcd")
#else
# define ACE_LD_DECORATOR_STR ACE_LIB_TEXT ("d")
#endif/* ACE_HAS_MFC */
# else/* _NDEBUG */
#if ACE_HAS_MFC == 1
# define ACE_LD_DECORATOR_STR ACE_LIB_TEXT ("mfc")
#endif/* ACE_HAS_MFC */
# endif/* _DEBUG */
#endif/* ACE_LD_DECORATOR_STR */
// Compiler sets _CPPRTTI if rtti is enabled.
#if defined (_CPPRTTI)
#if defined (ACE_LACKS_RTTI)
# undef ACE_LACKS_RTTI
#endif
#else
#if !defined (ACE_LACKS_RTTI)
# define ACE_LACKS_RTTI
#endif
#endif /* _CPPRTTI */
#if ! defined(_NATIVE_WCHAR_T_DEFINED)
#define ACE_LACKS_NATIVE_WCHAR_T
#endif
// Win Mobile still does thread exits differently than PC Windows.
#if defined (_WIN32_WCE)
#define ACE_ENDTHREADEX(STATUS) ExitThread ((DWORD) STATUS)
#else
#define ACE_ENDTHREADEX(STATUS) ::_endthreadex ((DWORD) STATUS)
#endif /* _WIN32_WCE */
#if (_MSC_VER >= 1400)
# include "ace/config-win32-msvc-8.h"
#elif (_MSC_VER >= 1300)
# include "ace/config-win32-msvc-7.h"
// FUZZ: disable check_for_msc_ver
#elif (_MSC_VER >= 1200)
# include "ace/config-win32-msvc-6.h"
#else
# error This version of Microsoft Visual C++ not supported.
#endif
#if defined(ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
// must have _MT defined to include multithreading
// features from win32 headers
# if !defined(_MT) && !defined (ACE_HAS_WINCE)
// *** DO NOT *** defeat this error message by defining _MT yourself.
// On MSVC, this is changed by selecting the Multithreaded
// DLL or Debug Multithreaded DLL in the Project Settings
// under C++ Code Generation.
#error You must link against multi-threaded libraries when using ACE (check your project settings)
# endif /* !_MT && !ACE_HAS_WINCE */
#endif /* ACE_MT_SAFE && ACE_MT_SAFE != 0 */
#include <malloc.h>
// Although ACE does have alloca() on this compiler/platform combination, it is
// disabled by default since it can be dangerous.Uncomment the following line
// if you ACE to use it.
//#define ACE_HAS_ALLOCA 1
#define ACE_LACKS_DIRENT_H
#define ACE_LACKS_DLFCN_H
#define ACE_LACKS_INTTYPES_H
#define ACE_LACKS_NETDB_H
#define ACE_LACKS_NET_IF_H
#define ACE_LACKS_NETINET_IN_H
#define ACE_LACKS_STDINT_H
#define ACE_LACKS_STROPTS_H
#define ACE_LACKS_SYS_IOCTL_H
#define ACE_LACKS_SYS_IPC_H
#define ACE_LACKS_SYS_MMAN_H
#define ACE_LACKS_SYS_RESOURCE_H
#define ACE_LACKS_SYS_SELECT_H
#define ACE_LACKS_SYS_SEM_H
#define ACE_LACKS_SYS_SOCKET_H
#define ACE_LACKS_SYS_TIME_H
#define ACE_LACKS_SYS_UIO_H
#define ACE_LACKS_SYS_WAIT_H
#define ACE_LACKS_UCONTEXT_H
#define ACE_LACKS_SEMAPHORE_H
#define ACE_LACKS_STRINGS_H
#define ACE_LACKS_PWD_H
#define ACE_LACKS_POLL_H
#define ACE_LACKS_SYS_SHM_H
#define ACE_LACKS_SYS_MSG_H
#define ACE_LACKS_NETINET_TCP_H
#define ACE_LACKS_TERMIOS_H
#define ACE_LACKS_REGEX_H
// Turn off warnings for /W4
// To resume any of these warning: #pragma warning(default: 4xxx)
// which should be placed after these defines
# if !defined (ALL_WARNINGS) && defined(_MSC_VER) && !defined(ghs) && !defined(__MINGW32__)
// #pragma warning(disable: 4101)// unreferenced local variable
# pragma warning(disable: 4127)/* constant expression for TRACE/ASSERT */
# pragma warning(disable: 4134)/* message map member fxn casts */
# pragma warning(disable: 4511)/* private copy constructors are good to have */
# pragma warning(disable: 4512)/* private operator= are good to have */
# pragma warning(disable: 4514)/* unreferenced inlines are common */
# pragma warning(disable: 4710)/* private constructors are disallowed */
# pragma warning(disable: 4705)/* statement has no effect in optimized code */
// #pragma warning(disable: 4701)// local variable *may* be used without init
// #pragma warning(disable: 4702)// unreachable code caused by optimizations
# pragma warning(disable: 4791)/* loss of debugging info in retail version */
// #pragma warning(disable: 4204)// non-constant aggregate initializer
# pragma warning(disable: 4275)/* deriving exported class from non-exported */
# pragma warning(disable: 4251)/* using non-exported as public in exported */
# pragma warning(disable: 4786)/* identifier was truncated to '255' characters in the browser information */
# pragma warning(disable: 4097)/* typedef-name used as synonym for class-name */
# pragma warning(disable: 4800)/* converting int to boolean */
# endif /* !ALL_WARNINGS && _MSV_VER && !ghs && !__MINGW32__ */
// STRICT type checking in WINDOWS.H enhances type safety for Windows
// programs by using distinct types to represent all the different
// HANDLES in Windows. So for example, STRICT prevents you from
// mistakenly passing an HPEN to a routine expecting an HBITMAP.
// Note that we only use this if we
# if defined (ACE_HAS_STRICT) && (ACE_HAS_STRICT != 0)
# if !defined (STRICT) /* may already be defined */
# define STRICT
# endif /* !STRICT */
# endif /* ACE_HAS_STRICT */
#include /**/ "ace/post.h"
#endif /* ACE_CONFIG_WIN32_MSVC_H */ 不知道这三个文件够不够? config.h
#define ACE_HAS_STANDARD_CPP_LIBRARY 1 - 去掉看看
回复 #16 winston 的帖子
有点奇怪,我重编译ACE,只有ACEd.dll是最新生成的,而ACEd.lib还是之前的未重新生成。将lib目录下的所有文件删了,确实会重新生成ACEd.dll和ACEd.lib两个文件。但是我重新编译程序后还是报错。
[ 本帖最后由 tiburon 于 2008-11-11 19:14 编辑 ] 这是我额外创建的另一个程序,现象一样,仍然会报错。DLL和Lib都是最新的。
#ifndef WINVER // 允许使用 Windows 95 和 Windows NT 4 或更高版本的特定功能。
#define WINVER 0x0500 //为 Windows98 和 Windows 2000 及更新版本改变为适当的值。
#endif
#ifndef _WIN32_WINNT // 允许使用 Windows NT 4 或更高版本的特定功能。
#define _WIN32_WINNT 0x0500 //为 Windows98 和 Windows 2000 及更新版本改变为适当的值。
#endif
#ifndef _WIN32_WINDOWS // 允许使用 Windows 98 或更高版本的特定功能。
#define _WIN32_WINDOWS 0x0510 //为 Windows Me 及更新版本改变为适当的值。
#endif
#ifndef _WIN32_IE // 允许使用 IE 4.0 或更高版本的特定功能。
#define _WIN32_IE 0x0600 //为 IE 5.0 及更新版本改变为适当的值。
#endif
#include "ace/streams.h"
#include "ace/Log_Msg.h"
#include "ace/Log_Msg_Callback.h"
#include "ace/Log_Record.h"
#include "ace/SOCK_Stream.h"
#include "ace/SOCK_Connector.h"
#include "ace/INET_Addr.h"
#include "ace/Singleton.h"
#include "ace/Message_Block.h"
#include "ace/Svc_Handler.h"
#include "ace/SOCK_Acceptor.h"
#include "ace/Reactor.h"
#include "ace/Acceptor.h"
#include "ace/Connector.h"
#include "ace/Reactor_Notification_Strategy.h"
#include "ace/Select_Reactor.h"
/************************************************************************
* *
* CLASS OF ClientService *
* *
************************************************************************/
class ClientService :
public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>
{
typedef ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> super;
public:
int open(void * = 0);
// Called when input is available from the client.
virtual int handle_input(ACE_HANDLE fd = ACE_INVALID_HANDLE);
// Called when output is possible.
virtual int handle_output(ACE_HANDLE fd = ACE_INVALID_HANDLE);
// Called when this handler is removed from the ACE_Reactor.
virtual int handle_close(ACE_HANDLE handle, ACE_Reactor_Mask close_mask);
void send(int p_length, char * p_buffer);
//FEZ::ClientHandler * m_handler;
ACE_TCHAR m_peer_name;
ACE_INET_Addr m_peer_addr;
char m_log;
};
/************************************************************************
* *
* CLASS OF ClientService *
* *
************************************************************************/
/*********************************************************************************************
Method :doExecute
Summary :线程主体函数
Parameters:NULL
return :void
2008-07-05 added by doug han
********************************************************************************************/
int ClientService::open(void *p)
{
if ( super::open(p) == -1 )
return -1;
//m_handler = SysCoreClientHandler::instance();
if ( this->peer().get_remote_addr(m_peer_addr) == 0 &&
m_peer_addr.addr_to_string(m_peer_name, 255) == 0 )
{
sprintf(m_log,
"Client ServiceConnection from %s\r\n",
m_peer_name);
//FEZCoreUtil::WriteLog(m_log);
}
std::string addr;
addr = m_peer_name;
int i = addr.find_first_of(':');
addr = addr.substr(0, i);
strcpy(m_peer_name, addr.c_str());
//SysCoreClientAddr::instance()->AddClient(this, m_peer_name, m_peer_addr.get_port_number());
return 0;
}
/*********************************************************************************************
Method :doExecute
Summary :线程主体函数
Parameters:NULL
return :void
2008-07-05 added by doug han
********************************************************************************************/
int ClientService::handle_input(ACE_HANDLE)
{
const size_t INPUT_SIZE = 4096;
char buffer;
ssize_t recv_cnt, send_cnt;
recv_cnt = this->peer().recv(buffer, sizeof(buffer));
if ( recv_cnt <= 0 )
{
sprintf(m_log,
"Client ServiceConnection closed %s\r\n",
m_peer_name);
//FEZCoreUtil::WriteLog(m_log);
return -1;
}
//m_handler->Extract(m_peer_name, m_peer_addr.get_port_number(), recv_cnt, buffer);
return 0;
}
/*********************************************************************************************
Method :doExecute
Summary :线程主体函数
Parameters:NULL
return :void
2008-07-05 added by doug han
********************************************************************************************/
int ClientService::handle_output (ACE_HANDLE)
{
ACE_Message_Block * mb;
ACE_Time_Value nowait(ACE_OS::gettimeofday());
while ( -1 != this->getq(mb, &nowait) )
{
ssize_t send_cnt = this->peer().send(mb->rd_ptr (), mb->length ());
if ( send_cnt == -1 )
{
ACE_ERROR((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), ACE_TEXT ("send")));
//FEZCoreUtil::WriteLog("Client ServiceSend err\r\n");
}
else
mb->rd_ptr(ACE_static_cast(size_t, send_cnt));
if ( mb->length() > 0 )
{
this->ungetq(mb);
break;
}
mb->release ();
}
return (this->msg_queue()->is_empty()) ? -1 : 0;
}
/*********************************************************************************************
Method :doExecute
Summary :线程主体函数
Parameters:NULL
return :void
2008-07-05 added by doug han
********************************************************************************************/
int ClientService::handle_close(ACE_HANDLE h, ACE_Reactor_Mask mask)
{
if ( mask == ACE_Event_Handler::WRITE_MASK )
return 0;
if ( this->peer().get_remote_addr(m_peer_addr) == 0 &&
m_peer_addr.addr_to_string(m_peer_name, 255) == 0 )
{
sprintf(m_log,
"Client ServiceConnection from %s closed\r\n",
m_peer_name);
//FEZCoreUtil::WriteLog(m_log);
}
std::string addr;
addr = m_peer_name;
int i = addr.find_first_of(':');
addr = addr.substr(0, i);
strcpy(m_peer_name, addr.c_str());
//SysCoreClientAddr::instance()->RemoveClient(m_peer_name, m_peer_addr.get_port_number());
return super::handle_close(h, mask);
}
/*********************************************************************************************
Method :doExecute
Summary :线程主体函数
Parameters:NULL
return :void
2008-07-05 added by doug han
********************************************************************************************/
void ClientService::send(int p_length, char * p_buffer)
{
ssize_t send_cnt;
send_cnt = this->peer().send(p_buffer, ACE_static_cast(size_t, p_length));
if ( send_cnt == p_length )
return;
if ( send_cnt == -1 && ACE_OS::last_error() != EWOULDBLOCK )
ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) %p\n"), ACE_TEXT ("send")));
if ( send_cnt == -1 )
send_cnt = 0;
ACE_Message_Block * mb;
size_t remaining = ACE_static_cast(size_t, (p_length - send_cnt));
ACE_NEW(mb, ACE_Message_Block(&p_buffer, remaining));
int output_off = this->msg_queue()->is_empty();
ACE_Time_Value nowait(ACE_OS::gettimeofday());
if ( this->putq(mb, &nowait) == -1 )
{
ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) %p; discarding data\n"), ACE_TEXT ("enqueue failed")));
mb->release ();
return;
}
if ( output_off )
this->reactor()->register_handler(this, ACE_Event_Handler::WRITE_MASK);
}
typedef ACE_Acceptor<ClientService, ACE_SOCK_ACCEPTOR> ClientAcceptor;
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
template class ACE_Acceptor<ClientService, ACE_SOCK_ACCEPTOR>;
template class ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
#pragma instantiate ACE_Acceptor<ClientService, ACE_SOCK_ACCEPTOR>
#pragma instantiate \
ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
ClientAcceptor g_clientAcceptor;
int main(int argc, char * argv[])
{
ACE::init();
ACE_Select_Reactor * selectReactor = new ACE_Select_Reactor();
ACE_Reactor * coreReactor = new ACE_Reactor(selectReactor, 1);
ACE_Reactor::instance(coreReactor, 1);
ACE_INET_Addr port_to_listen(1999);
if ( g_clientAcceptor.open(port_to_listen) == -1 )
{
return FALSE;
}
ACE::fini();
return 0;
} 在出现错误的时候,VC下面的窗口会出现一个异常信息,我记得和RTTI有关,但是细节记不得了。你可以贴出来。
应该不是代码和ACE的问题,肯定是哪个地方出现了错误或遗漏。奇怪的问题,经常都有简单的答案。
回复 #19 winston 的帖子
Core.exe 中的 0x10159057 (ACEd.dll) 处最可能的异常: 0xC0000005: 读取位置 0x00000004 时发生访问冲突 。Core.exe 中的 0x7c812a5b 处最可能的异常: Microsoft C++ exception: __non_rtti_object @ 0x0248f614 。
Core.exe 中的 0x7c812a5b 处未处理的异常: Microsoft C++ exception: __non_rtti_object @ 0x0248f614 。
Core.exe 中的 0x10159057 (ACEd.dll) 处最可能的异常: 0xC0000005: 读取位置 0x00000004 时发生访问冲突 。
Core.exe 中的 0x7c812a5b 处最可能的异常: Microsoft C++ exception: __non_rtti_object @ 0x0248f614 。
Core.exe 中的 0x7c812a5b 处未处理的异常: Microsoft C++ exception: __non_rtti_object @ 0x0248f614 。
太崇拜你了,这也知道。