gotoを恐れず使う兵共がfinallyや多重breakを語るスレat TECH
gotoを恐れず使う兵共がfinallyや多重breakを語るスレ - 暇つぶし2ch735:デフォルトの名無しさん
08/02/17 03:32:45
>>719 でけた。TRY~END_TRYの中からreturn出来ないけど。
typedef struct ex_handler_rec_ ex_handler_rec_;
struct ex_handler_rec_ {
    ex_handler_rec_ *volatile prev_;
    jmp_buf jbuf_;
    const char *volatile ex_type_;
    void *volatile ex_data_;
};
ex_handler_rec_ *volatile current_handler_ = NULL;

#define EX_ABBREV(x) x
#define TRY { \
ex_handler_rec_ EX_ABBREV(ex_handler_); \
int EX_ABBREV(need_rethrow_) = 0; \
if (0) BREAK_TRY; /* mandate finally clause */ \
EX_ABBREV(ex_handler_).prev_ = current_handler_; \
current_handler_ = &EX_ABBREV(ex_handler_); \
if (setjmp(EX_ABBREV(ex_handler_).jbuf_) == 0) {

#define BREAK_TRY goto EX_ABBREV(break_entry_)
#define RETHROW goto EX_ABBREV(rethrow_entry_)

#define CATCH(extype) \
} else if (!extype || !strcmp(extype, EX_ABBREV(ex_handler_).ex_type_)) { \
   void *EX_ABBREV(ex_data) = EX_ABBREV(ex_handler_).ex_data_;
#define CATCH_ALL \
} else if (1) { \
   void *EX_ABBREV(ex_data) = EX_ABBREV(ex_handler_).ex_data_;


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch