⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exception.c

📁 c语言是面向过程的程序语言
💻 C
字号:
/* ****************************** * Object Oriented Programming in C * * Author: Laurent Deniau, Laurent.Deniau@cern.ch * * For more information, please see the paper: * http://home.cern.ch/ldeniau/html/oopc/oopc.html * ****************************** */#include <stdio.h>#include <exception.h>/* global stack of exception context */struct _exceptionContext_ *_currentExceptionContext_ = NULL;void_exceptionThrow_(int exception){  /* no exception context saved, exit program */  if (!_currentExceptionContext_) exit(exception);   /* free pointers stored on the current exception context pointers stack */  while(_currentExceptionContext_->ptr) {     _currentExceptionContext_->ptr->fct(_currentExceptionContext_->ptr->ptr);     _currentExceptionContext_->ptr = _currentExceptionContext_->ptr->next;   }   /* jump to previous exception context */  longjmp(_currentExceptionContext_->context, exception); } struct _protectedPointer_ _newProtectedPointer_(struct _protectedPointer_ *ptr,                       void* ptr2protect,                       void (*ptr_free)(void *)) {   if (_currentExceptionContext_) {     ptr->next = _currentExceptionContext_->ptr;     ptr->ptr  = ptr2protect;     ptr->fct  = ptr_free;     _currentExceptionContext_->ptr = ptr;   }   return *ptr; } #ifdef DEBUG_THROWvoid_exceptionThrowDebug_(char const* _file_, int _line_, char const* _func_,		      char const* _exception_, int exception){  fprintf(stderr, "%s(%d):%s: exception '%s' (id %d) thrown\n",	  _file_, _line_, _func_, _exception_, exception);  _exceptionThrow_(exception);}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -