Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 647
  • Last Modified:

evc++ /EHa option cause error LNK2019

Hi,

i,m trying to use /EHa option in evc++ to use a TRY CATCH block catching also asyncrounouns errors (like index out of bound etc...)

the problem is that while linking it gives me this error:

DiagTool.obj : error LNK2019: unresolved external symbol ___CxxLongjmpUnwind@4 referenced in function "public: virtual int __thiscall CDiagToolApp::InitInstance(void)" (?InitInstance@CDiagToolApp@@UAEHXZ)

Project otpions are:

/nologo /W3 /Zi /Od /I "..\jpeglib\\" /D "DEBUG" /D "_i386_" /D UNDER_CE=$(CEVersion) /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "UNICODE" /D "_UNICODE" /D "_X86_" /D "x86" /D "_WIN32_WCE_CEPC" /D "_AFXDLL" /FR"X86Dbg/" /Fo"X86Dbg/" /Fd"X86Dbg/" /Gs8192 /GF /c /EHa

and the piece of code is this one:

      
TRY
	{
		int intArray[5] = { 16, 2, 77, 40, 12071 }; 
		int mtp;

		for(int i=-1;i<50;i++)
		{
			intArray[i]=i;
			mtp=intArray[i];
		}
		
	}
	CATCH( CException, e )
    {
		AfxMessageBox(_T("Problem here"));
	}
	END_CATCH

Open in new window

0
rileo8
Asked:
rileo8
  • 7
  • 5
1 Solution
 
jkrCommented:
Are you just adding the compoiler option manually? Try to set that is VS (from the docs):

------------------------------------>8-----------------------------------

To set this compiler option in the Visual Studio development environment
Open the project's Property Pages dialog box. For details, see How to: Open Project Property Pages.

Click the C/C++ folder.

Click the Code Generation property page.

Modify the Enable C++ Exceptions property.

------------------------------------>8-----------------------------------
0
 
rileo8Author Commented:
Hi,

i'm usinf EVC++ 4.0 so the only way to add it is by hand..

from the help:

 Project Options -> Type /EH in the text box, adding the desired exception-handling arguments.
0
 
jkrCommented:
Hmm, could you give it a try to set that in the project options?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
rileo8Author Commented:
I already set it, project oprions are:

/nologo /W3 /Zi /Od /I "..\jpeglib\\" /D "DEBUG" /D "_i386_" /D UNDER_CE=$(CEVersion) /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "UNICODE" /D "_UNICODE" /D "_X86_" /D "x86" /D "_WIN32_WCE_CEPC" /D "_AFXDLL" /FR"X86Dbg/" /Fo"X86Dbg/" /Fd"X86Dbg/" /Gs8192 /GF /c /EHa

so you can see /EHa at the end of the string

The problem is that wihout it it catch only c++ exception while with it it should catch also win32 exception....but it gives that error...
0
 
jkrCommented:
Honestly, I wouldn't try to catch SEH exceptions with a C++ exception handler, these are simply two different things. Rather try to
LONG
WINAPI
MyExceptionHandler(LPEXCEPTION_POINTERS pe) {

    AfxMessageBox(_T("Problem here"));

    return EXCEPTION_EXECUTE_HANDLER;
}

//...

SetUnhandledExceptionFilter(MyExceptionHandler);

TRY
	{
		int intArray[5] = { 16, 2, 77, 40, 12071 }; 
		int mtp;

		for(int i=-1;i<50;i++)
		{
			intArray[i]=i;
			mtp=intArray[i];
		}
		
	}
	CATCH( CException, e )
    {
		AfxMessageBox(_T("Problem here"));
	}
	END_CATCH

Open in new window

0
 
rileo8Author Commented:
I did like this:


LONG WINAPI OurCrashHandler(EXCEPTION_POINTERS * /*ExceptionInfo*/)
{
    AfxMessageBox(_T("TAKEN"));

    return 0;
}

BOOL CDiagToolApp::InitInstance()
{

      SetUnhandledExceptionFilter(OurCrashHandler);

...

but it gives me compile error:

 error C2065: 'SetUnhandledExceptionFilter' : undeclared identifier
0
 
jkrCommented:
Ooops, sorry, my fault - "Windows CE: Unsupported.". But, since you are mainly after SEH exceptions, does the following work for you?
//...
        __try
	{
		int intArray[5] = { 16, 2, 77, 40, 12071 }; 
		int mtp;

		for(int i=-1;i<50;i++)
		{
			intArray[i]=i;
			mtp=intArray[i];
		}
		
	}
	__except(1)
        {
		AfxMessageBox(_T("Problem here"));
	}

Open in new window

0
 
rileo8Author Commented:
Now the code is like this:


      __try
    {
            regman->ReadString(_T("Language"));
      }
      __except(1)
    {
        AfxMessageBox(_T("Problem here"));
    }


and i don't have /EHa in the project settings

regman is a null pointer so rise an exception and it seems to work correctly.
0
 
jkrCommented:
That's what is is supposed to do ;o)
0
 
rileo8Author Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for rileo8's comment http:/Q_27361360.html#36815462

for the following reason:

Solved the issue
0
 
jkrCommented:
Um, since your comment you suggested for closing this Q is basically what I wrote earlier - why are you not just closing this question?
0
 
jkrCommented:
http://www.experts-exchange.com/Programming/Languages/CPP/Q_27361360.html?cid=1572#a36815385 already lines out what now should be the solution now, thus the objection.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now