View previous topic :: View next topic |
Author |
Message |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Wed Mar 04, 2009 12:29 am Post subject: [C++]Handling Exception? |
|
|
Well, i don't know what's the best method to handle an exception, i mean in delphi i just do it like:
Code: | begin
try
//Code the fails here
except
exit; //exits from the procedure without showing access violation or any error box unless you're doing debug check
end;
end. |
but in C++ i see people use:
EXCEPTION_EXECUTE_HANDLER
or
some_except& e
or
EAccessViolation EErrorCheck
try/catch-except
which one to use ? and what's the different ?
i'll be more specific when i get home. |
|
Back to top |
|
 |
Spawnfestis GO Moderator
Reputation: 0
Joined: 02 Nov 2007 Posts: 1746 Location: Pakistan
|
Posted: Wed Mar 04, 2009 5:31 am Post subject: |
|
|
Roteeeeeeeeeem wrote: | what's the best method to handle an exception |
Code: | __try {
// Rot1 code
}
__except(EXCEPTION_EXECUTE_HANDLER) {
// Save Rot1
} |
_________________
CLICK TO HAX MAPLESTORAY ^ !!!! |
|
Back to top |
|
 |
S3NSA :3
Reputation: 1
Joined: 06 Dec 2006 Posts: 1908 Location: England.
|
|
Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Wed Mar 04, 2009 4:12 pm Post subject: |
|
|
If you want smaller and faster code, don't use exeptions. They're slowwwwwwwwww and hog resources. |
|
Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Wed Mar 04, 2009 6:10 pm Post subject: |
|
|
Jani wrote: | If you want smaller and faster code, don't use exeptions. They're slowwwwwwwwww and hog resources. |
On this note, for anyone using c++ who does not want to support exception handling, simply do the following for each of your functions:
Code: | void SomeClass::SomeFunc(void) throw()
{
// code here
} |
|
|
Back to top |
|
 |
tombana Master Cheater
Reputation: 2
Joined: 14 Jun 2007 Posts: 456 Location: The Netherlands
|
Posted: Thu Mar 05, 2009 9:36 am Post subject: |
|
|
Flyte wrote: |
On this note, for anyone using c++ who does not want to support exception handling, simply do the following for each of your functions:
Code: | void SomeClass::SomeFunc(void) throw()
{
// code here
} |
|
So what exactly does that do?
And you're example is a class function, can it also be applied to normal functions? |
|
Back to top |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Thu Mar 05, 2009 9:45 am Post subject: |
|
|
tombana wrote: | Flyte wrote: |
On this note, for anyone using c++ who does not want to support exception handling, simply do the following for each of your functions:
Code: | void SomeClass::SomeFunc(void) throw()
{
// code here
} |
|
So what exactly does that do?
And you're example is a class function, can it also be applied to normal functions? |
Doesn't matter if it's a part of a class or not. |
|
Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Thu Mar 05, 2009 10:08 am Post subject: |
|
|
Flyte wrote: | On this note, for anyone using c++ who does not want to support exception handling, simply do the following for each of your functions | Just don't enable it. VS has it enabled by default, you may disable it from the preferences. |
|
Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Thu Mar 05, 2009 2:34 pm Post subject: |
|
|
Jani wrote: | Just don't enable it. VS has it enabled by default, you may disable it from the preferences. |
True enough, I just do it because some functions you may actually want exception handling.
tombana wrote: | So what exactly does that do?
And you're example is a class function, can it also be applied to normal functions? |
It strips any code from the function that would be generated with exception handling in mind. It's basically telling the compiler: "I'm perfect, I don't throw exceptions, fuck off."
It can be used in normal functions. |
|
Back to top |
|
 |
|