mirror of
https://github.com/throwtheswitch/cexception.git
synced 2026-09-14 22:29:58 +00:00
* Added fallback handler for Throws that happen when no Try..Catch has been specified.
git-svn-id: http://cexception.svn.sourceforge.net/svnroot/cexception/trunk@18 50f63946-2846-0410-8d77-f904c773002e
This commit is contained in:
+7
-3
@@ -1,6 +1,6 @@
|
||||
#include "CException.h"
|
||||
|
||||
volatile CEXCEPTION_FRAME_T CExceptionFrames[CEXCEPTION_NUM_ID];
|
||||
volatile CEXCEPTION_FRAME_T CExceptionFrames[CEXCEPTION_NUM_ID] = { 0 };
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
// Throw
|
||||
@@ -9,11 +9,15 @@ void Throw(CEXCEPTION_T ExceptionID)
|
||||
{
|
||||
unsigned int MY_ID = CEXCEPTION_GET_ID;
|
||||
CExceptionFrames[MY_ID].Exception = ExceptionID;
|
||||
longjmp(*CExceptionFrames[MY_ID].pFrame, 1);
|
||||
if (CExceptionFrames[MY_ID].pFrame)
|
||||
{
|
||||
longjmp(*CExceptionFrames[MY_ID].pFrame, 1);
|
||||
}
|
||||
CEXCEPTION_NO_CATCH_HANDLER(MY_ID);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
// Explaination of what it's all for:
|
||||
// Explanation of what it's all for:
|
||||
//------------------------------------------------------------------------------------------
|
||||
/*
|
||||
#define Try
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
//To Use CException, you have a number of options:
|
||||
//1. Just include it and run with the defaults
|
||||
//2. Define any of the following symbols at the command line to override them
|
||||
@@ -33,6 +39,11 @@
|
||||
#define CEXCEPTION_T unsigned int
|
||||
#endif
|
||||
|
||||
//This is an optional special handler for when there is no global Catch
|
||||
#ifndef CEXCEPTION_NO_CATCH_HANDLER
|
||||
#define CEXCEPTION_NO_CATCH_HANDLER(id)
|
||||
#endif
|
||||
|
||||
//exception frame structures
|
||||
typedef struct {
|
||||
jmp_buf* pFrame;
|
||||
@@ -67,4 +78,9 @@ extern volatile CEXCEPTION_FRAME_T CExceptionFrames[];
|
||||
//Throw an Error
|
||||
void Throw(CEXCEPTION_T ExceptionID);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
|
||||
#endif // _CEXCEPTION_H
|
||||
|
||||
Reference in New Issue
Block a user