📄 exception.h
字号:
#ifndef MY_EXCEPTION_CATCH_TEST
#define MY_EXCEPTION_CATCH_TEST
#include <stdlib.h>
// the length of an element of the exception stack
#define STACK_TYPE_SIZE (sizeof(void*))
// the max exception stack size can be configured by users
#define MAX_EXCEPTION_STACK_SIZE 8
// the type of address can be configured according to users' machines
typedef unsigned long ADDR; // default 32 bytes
class _sys_ExceptStack
{
private:
void* except_stack_queue[MAX_EXCEPTION_STACK_SIZE];
void **tail, **front;
bool bFull, bEmpty;
int tempCounter;
public:
_sys_ExceptStack(void);
~_sys_ExceptStack(void);
void AddException(void *pE);
void* GetException(void);
inline void ClearCounter(void);
};
inline void _sys_ExceptStack::ClearCounter(void)
{
while(tempCounter > 0)
GetException();
}
extern _sys_ExceptStack __sysExceptionStack;
#define THROW(expr) { __sysExceptionStack.AddException(expr); }
#define TRY {
#define CATCH(type, var) type var = (type)__sysExceptionStack.GetException(); \
if(var == NULL); \
else {
#define END_TRY \
__sysExceptionStack.ClearCounter(); exit(-1); } \
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -