473,804 Members | 3,178 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Handle C++ exception and structured exception together

Hello everyone,
I am learning set_se_translat or, 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 2341
George2 wrote:
Hello everyone,
I am learning set_se_translat or, 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(CSeExcept ion *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_translat or, 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_translat or, 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(CSeExcept ion *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_translat or, 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(CSeExcep tion *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(CSeExce ption *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
3178
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 Question ----------- I am looking for a list of popular compilers and/or platforms that *do not* support native C++ exceptions. Any pointers in this
11
2888
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 return code (not generating error/exception) so it is more compatible with other programming language.
3
1282
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 structured programming lang?? Thanks to all those who are gonna answer.. -ambika
3
1919
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 debugger). In debug build, the exception is caught and reported gracefully to the user. When I build the release version and run it, the SEH frame does not catch the exception and the application crashes. Has anyone had a similar experience and if...
4
2861
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 intranet .asp program works, but as soon as it tries to access the database for normal users, it gives us an "unspecified error" and that it can't access the data base. As the administrator, I found my access was relatively stable. Anyone else...
9
1851
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 a); void test() { testfunc func = NULL;
1
1503
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 structured exception, what is the differences between structure exception and our normal C++ exception, like bad_alloc and various
1
1406
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 implementation knows that only a few standard C library functions (such as atexit() and qsort()) can throw exceptions,
9
1932
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 months in Java, I am thinking why Win32 APIs or even .Net documentation not clear on which methods will throw exception or what exceptions can be expected. Jave APIs clearly define exceptions that can be expected and enforces that we handle them. ...
0
9584
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10337
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9160
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5654
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2995
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.