473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Handle C++ exception and structured exception together

Hello everyone,
I am learning set_se_translator, and there are some good resources
about how to translate structured exception into C++ exception, like,

http://www.codeproject.com/KB/cpp/seexception.aspx

1.

What makes me confused is, when we are talking about translate, it
means both structured exception and C++ exception may occur in a C++
program, right?

2.

But from build option, we can select either /EHa or /EHsc, means we
can only select one type of exception, either asynchronous
(structured) or synchronous (C++ exception).

(1) and (2) are conflict?
thanks in advance,
George
Jan 24 '08 #1
5 2320
George2 wrote:
Hello everyone,
I am learning set_se_translator, and there are some good resources
about how to translate structured exception into C++ exception, like,

http://www.codeproject.com/KB/cpp/seexception.aspx
LOL
this code looks like coming from a clown:

catch(CSeException *e)
{
e->ReportError(MB_OK | MB_ICONSTOP);
e->Delete();
}

Wondering what they do in Delete() method. Hope not "delete this"

BTW http://www.parashift.com/c++-faq-lit....html#faq-17.7 is
missing that the best way is to catch const reference
Jan 24 '08 #2
George2 wrote:
Hello everyone,
I am learning set_se_translator, and there are some good resources
about how to translate structured exception into C++ exception, like,

http://www.codeproject.com/KB/cpp/seexception.aspx

1.

What makes me confused is, when we are talking about translate, it
means both structured exception and C++ exception may occur in a C++
program, right?

2.

But from build option, we can select either /EHa or /EHsc, means we
can only select one type of exception, either asynchronous
(structured) or synchronous (C++ exception).

(1) and (2) are conflict?
thanks in advance,
George
My understanding is that you need to use /EHsc, because your code will
catch C++ exceptions; the code that throws structured exceptions has
already been compiled into the libraries your code uses. Did not try it
myself though.

-Pavel
Jan 25 '08 #3
anon wrote:
George2 wrote:
>Hello everyone,
I am learning set_se_translator, and there are some good resources
about how to translate structured exception into C++ exception, like,

http://www.codeproject.com/KB/cpp/seexception.aspx

LOL
this code looks like coming from a clown:

catch(CSeException *e)
{
e->ReportError(MB_OK | MB_ICONSTOP);
e->Delete();
}

Wondering what they do in Delete() method. Hope not "delete this"
I thought "delete this" was not bad-bad, although certainly not ideal.
Sometimes there is no good alternative to at least indirect "delete
this" or its equivalent ... or I simply do not know one. Do you?
Jan 25 '08 #4
Pavel wrote:
anon wrote:
>George2 wrote:
>>Hello everyone,
I am learning set_se_translator, and there are some good resources
about how to translate structured exception into C++ exception, like,

http://www.codeproject.com/KB/cpp/seexception.aspx

LOL
this code looks like coming from a clown:

catch(CSeException *e)
{
e->ReportError(MB_OK | MB_ICONSTOP);
e->Delete();
}

Wondering what they do in Delete() method. Hope not "delete this"

I thought "delete this" was not bad-bad, although certainly not ideal.
Sometimes there is no good alternative to at least indirect "delete
this" or its equivalent ... or I simply do not know one. Do you?
http://www.parashift.com/c++-faq-lit...html#faq-16.15

Do you have an example where "delete this" would be good? Or at least
not bad?
Jan 25 '08 #5
anon wrote:
Pavel wrote:
>anon wrote:
>>George2 wrote:
Hello everyone,
....
>>>
LOL
this code looks like coming from a clown:

catch(CSeException *e)
{
e->ReportError(MB_OK | MB_ICONSTOP);
e->Delete();
}

Wondering what they do in Delete() method. Hope not "delete this"

I thought "delete this" was not bad-bad, although certainly not ideal.
Sometimes there is no good alternative to at least indirect "delete
this" or its equivalent ... or I simply do not know one. Do you?

http://www.parashift.com/c++-faq-lit...html#faq-16.15
Sure, and the synposis of the answer to this FAQ is (quoting):
"As long as you're careful, it's OK for an object to commit suicide
(delete this)."
Do you have an example where "delete this" would be good? Or at least
not bad?
virtual Delete() or destroy() function is one of the OK ways to free the
object's memory (after freeing all other resources owned by the object,
if any) when the object knows how to free the memory it occupies in most
general case. When the memory is to be freed via delete, the function
has to call delete.

The technique has its pros and contras (IMHO mostly pros) when compared
with the alternatives I know. Do you know a clearly superior alternative?

-Pavel
Jan 26 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Bill Davidson | last post by:
Hi there, Please forgive me for posting this article on multiple groups. Being new in the newsgroups, I was not sure which group would have been appropriate for my question. Sorry. My...
11
by: adi | last post by:
Dear all, This is more like a theoretical or conceptual question: which is better, using exception or return code for a .NET component? I had created a COM object (using VB6), which uses...
3
by: ambika | last post by:
Hello, I have a very basic doubt. Why is C called a structured programming language??why structured? C++ is called a Object Oriented language 'cos it obeys the OOP's concepts..Why is C called a...
3
by: HairlipDog58 | last post by:
I have a VC++6 project where I need to delay load a DLL. I used a structured exception handling frame and all seems to work when I build the debug version and run it (either in or out of the...
4
by: Troy | last post by:
We recently installed the .Net framework on a windows 2000 server. Shortly after that we experienced intermitant problems running a web based program that accesses an Access 2002 database. The...
9
by: mos | last post by:
Hi! When call a null function pointer will cause a execption, but it can't be caught as std::exception, then which exception it is? The following code is a example: typedef void (*testfunc)(int...
1
by: George2 | last post by:
Hello everyone, I am learning structured exception from, http://msdn2.microsoft.com/en-us/library/ms681409(VS.85).aspx I read a couple of links from MSDN, but still confused what is...
1
by: George2 | last post by:
Hello everyone, As far as I know, C function does not throw exception. But Bjarne said in his book, section 14.8 Exception and Efficiency, -------------------- In particular, an...
9
by: =?Utf-8?B?UmFq?= | last post by:
How do I know which methods will throw exception when I am using FCL or other third party .Net library? I am developer of mostly native Windows applications and now .Net. After working few...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.