C++ error C2712: Cannot use __try in functions that require object unwinding

Results 1 to 3 of 3
  1. #1
    Member Veon is offline
    MemberRank
    Nov 2011 Join Date
    Locating TargetLocation
    85Posts

    ! C++ error C2712: Cannot use __try in functions that require object unwinding

    I'm trying to build my Gunz project but can't seem to figure out this error right here.

    " error C2712: Cannot use __try in functions that require object unwinding "

    Code:
    void MSocketThread::Run()
    {
    	__try
    	{
    			//throw(pThread);
    		while(true) {	// Waiting for SafeUDP Settting...
    			DWORD dwVal = WaitForSingleObject(m_KillEvent.GetEvent(), 100);
    			if (dwVal == WAIT_OBJECT_0) {
    				return;
    			} else if (dwVal == WAIT_TIMEOUT) {
    				if (m_pSafeUDP)
    					break;
    			}
    		}
    
    		WSAEVENT EventArray[WSA_MAXIMUM_WAIT_EVENTS];
    		WORD wEventIndex = 0;
    
    		bool bSendable = false;
    		WSANETWORKEVENTS NetEvent;
    		WSAEVENT hFDEvent = WSACreateEvent();
    		EventArray[wEventIndex++] = hFDEvent;
    		EventArray[wEventIndex++] = m_ACKEvent.GetEvent();
    		EventArray[wEventIndex++] = m_SendEvent.GetEvent();
    		EventArray[wEventIndex++] = m_KillEvent.GetEvent();
    
    		WSAEventSelect(m_pSafeUDP->GetLocalSocket(), hFDEvent, FD_READ|FD_WRITE);
    
    		while(TRUE) {
    			DWORD dwReturn = WSAWaitForMultipleEvents(wEventIndex, EventArray, FALSE, SAFEUDP_SAFE_MANAGE_TIME, FALSE);
    			if (dwReturn == WSA_WAIT_TIMEOUT) {					// Time
    				m_pSafeUDP->LockNetLink();
    				SafeSendManage();
    				m_pSafeUDP->UnlockNetLink();
    			} else if (dwReturn == WSA_WAIT_EVENT_0) {			// Socket Event
    				WSAEnumNetworkEvents(m_pSafeUDP->GetLocalSocket(), hFDEvent, &NetEvent);
    				if ((NetEvent.lNetworkEvents & FD_READ) == FD_READ) {
    	//				OutputDebugString("SUDP> FD_READ \n");
    					m_pSafeUDP->LockNetLink();
    					Recv();
    					m_pSafeUDP->UnlockNetLink();
    				} 
    				if ((NetEvent.lNetworkEvents & FD_WRITE) == FD_WRITE) {
    					bSendable = true;
    	//				OutputDebugString("SUDP> FD_WRITE \n");
    				}
    			} else if (dwReturn == WSA_WAIT_EVENT_0 + 1) {		// ACK Send Event
    	//			OutputDebugString("SUDP> ACK_EVENT \n");
    				FlushACK();
    			} else if (dwReturn == WSA_WAIT_EVENT_0 + 2) {		// Packet Send Event
    	//			OutputDebugString("SUDP> SEND_EVENT \n");
    				if (bSendable == true)
    					FlushSend();
    			} else if (dwReturn == WSA_WAIT_EVENT_0 + 3) {		// Kill the Thread
    				break;	// Stop Thread
    			}
    		}
    
    		WSACloseEvent(hFDEvent);
    
    		// Clear Queues
    		LockSend();
    		{
    			for (SendListItor itor = m_SendList.begin(); itor != m_SendList.end(); ) {
    				delete (*itor);
    				itor = m_SendList.erase(itor);
    			}
    		}
    		{
    			for (SendListItor itor = m_TempSendList.begin(); itor != m_TempSendList.end(); ) {
    				delete (*itor);
    				itor = m_TempSendList.erase(itor);
    			}
    		}
    		UnlockSend();
    
    		LockACK();
    		{
    			for (ACKSendListItor itor = m_ACKSendList.begin(); itor != m_ACKSendList.end(); ) {
    				delete (*itor);
    				itor = m_ACKSendList.erase(itor);
    			}
    		}
    		{
    			for (ACKSendListItor itor = m_TempACKSendList.begin(); itor != m_TempACKSendList.end(); ) {
    				delete (*itor);
    				itor = m_TempACKSendList.erase(itor);
    			}
    		}
    		UnlockACK();
    	}
    	__except(this->CrashDump(GetExceptionInformation())) 
    	{
    #ifndef _PUBLISH
    		char szFileName[_MAX_DIR];
    		GetModuleFileName(NULL, szFileName, _MAX_DIR);
    		HANDLE hProcess = MProcessController::OpenProcessHandleByFilePath(szFileName);
    		TerminateProcess(hProcess, 0);
    #endif
    	}
    
    }
    Appreciate all the help.


  2. #2
    Novice Mister Exe is offline
    MemberRank
    Dec 2016 Join Date
    2Posts

    Re: C++ error C2712: Cannot use __try in functions that require object unwinding


  3. #3
    Valued Member Keristrasza is offline
    MemberRank
    Jun 2015 Join Date
    128Posts

    Re: C++ error C2712: Cannot use __try in functions that require object unwinding

    Just remove the __try/__except blocks



Advertisement