Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
|
Visual C++ Questions specific to Microsoft's Visual C++. For questions not specific to this Microsoft version, use the C++ Programming forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 27th, 2006, 04:57 AM
Authorized User
 
Join Date: Apr 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Warning C4530: C++ exception handler used, but unw

Hi

I am using embedded visual C++ and new to it.

I have problem when I want to use try/catch. my try/catch code is as below:

try
{
m_oaItem.Add(pItem);
SetModifiedFlag();
m_iCurPosition = (m_oaItem.GetSize() - 1);
}
catch (CMemoryException* perr)
{
AfxMessageBox("Out of Memory", MB_ICONSTOP | MB_OK);
if (pItem)
{
delete pItem;
pItem = NULL;
}
perr->Delete();
}

When I build the application it give me error and warning as below:

C:\Documents and Settings\user1\My Documents\MobileInventory\MobileInventoryDoc.cpp(9 3) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify -GX
C:\Documents and Settings\user1\My Documents\MobileInventory\MobileInventoryDoc.cpp(1 00) : error C2665: 'AfxMessageBox' : none of the 2 overloads can convert parameter 1 from type 'char [14]'

I have tried solution below:

Project --> Settings... --> C/C++
Under "Category" Select C++ Language and check the "Enable exception handling". You can now do a rebuild all. You will prompted to save this project setting when you exit the IDE.

But I cannot find "Enable exception handling" option in the dialog in embedded Visual C++.

Can someone pls help, thanks in advance.

Best Regards

 
Old April 27th, 2006, 08:59 PM
Authorized User
 
Join Date: Apr 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

after 1 days struggled finally get the solution as below:

---------------------------------------------------------------------------

Windows CE 3.0 and earlier (versions targetted by eVC 3.0) do not support
C++ SEH, so you cannot use try/catch (and thus specifying -GX wouldn't help
you). You can use C exception handling (try/except), however.

For Windows CE 4.0 and later (use eVC 4.0 for those targets), it depends on
the actual Windows CE configuration if C++ SEH is supported. If it is, you
can use try/catch, but you do have to manually add -GX to the compiler
command line. You do so by clicking the Project\Settings... menu item in
eVC, select the C/C++ tab, and then go into the edit box at the bottom of
that dialog where the command line is and adding "-GX".

---------------------------------------------------------------------------

Or you can view solution at: http://www.tech-archive.net/Archive/...4-03/0372.html

Regards

 
Old April 27th, 2006, 09:00 PM
Authorized User
 
Join Date: Apr 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by bluebeta
 after 1 days struggled finally get the solution as below:

---------------------------------------------------------------------------

Windows CE 3.0 and earlier (versions targetted by eVC 3.0) do not support
C++ SEH, so you cannot use try/catch (and thus specifying -GX wouldn't help
you). You can use C exception handling (try/except), however.

For Windows CE 4.0 and later (use eVC 4.0 for those targets), it depends on
the actual Windows CE configuration if C++ SEH is supported. If it is, you
can use try/catch, but you do have to manually add -GX to the compiler
command line. You do so by clicking the Project\Settings... menu item in
eVC, select the C/C++ tab, and then go into the edit box at the bottom of
that dialog where the command line is and adding "-GX".

---------------------------------------------------------------------------

Or you can view solution at: http://www.tech-archive.net/Archive/...4-03/0372.html

Regards

After adding "-GX" in command line, and then Rebuild All.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Warning Message (Exception ex) dbcook8 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 December 1st, 2008 05:18 PM
Event handler samir_katore Pro VB 6 6 June 8th, 2006 01:22 PM
Problem with tag handler Syed BOOK: Professional Jakarta Struts 0 June 20th, 2005 11:01 AM
Event handler problem carro123 Javascript How-To 1 May 20th, 2005 03:30 PM
PreDefined Event Handler mark C# 1 June 7th, 2003 04:47 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.