mmozeiko
Yes, for C code RTTI and regular exceptions doesn't mean anything. On Windows there is possibility to use SEH exceptions even in C code (with __try/__except keywords, not try/catch). They are part of OS and compiler generates additional information to support it. You can't really turn them off, but if you don't use them then you shouldn't see any extra penalty at runtime.
Other than that, there is not nothing else that you can turn off for C mode.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | LONG WINAPI VectoredHandlerSkip1( struct _EXCEPTION_POINTERS *ExceptionInfo ) { PCONTEXT Context; Sequence++; Context = ExceptionInfo->ContextRecord; Actual[0] = 0xcc; #ifdef _AMD64_ Context->Rip++; #else Context->Eip++; #endif return EXCEPTION_CONTINUE_EXECUTION; } |
1 2 3 4 5 | void IllegalInst() { char *ptr = 0; *ptr = 0; } |
1 2 3 4 5 6 7 | __try { function_pointer_to_dll_func(app_state); // function pointer is not null } __except { // 1. We want to know that an exception happened (at all) // 2. And this is where we want to end up to continue execution } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | #define WIN32_EXCEPTION_LIST \ FUN(EXCEPTION_ACCESS_VIOLATION) \ FUN(EXCEPTION_ARRAY_BOUNDS_EXCEEDED) \ FUN(EXCEPTION_BREAKPOINT) \ FUN(EXCEPTION_DATATYPE_MISALIGNMENT) \ FUN(EXCEPTION_FLT_DENORMAL_OPERAND) \ FUN(EXCEPTION_FLT_DIVIDE_BY_ZERO) \ FUN(EXCEPTION_FLT_INEXACT_RESULT) \ FUN(EXCEPTION_FLT_INVALID_OPERATION) \ FUN(EXCEPTION_FLT_OVERFLOW) \ FUN(EXCEPTION_FLT_STACK_CHECK) \ FUN(EXCEPTION_ILLEGAL_INSTRUCTION) \ FUN(EXCEPTION_IN_PAGE_ERROR) \ FUN(EXCEPTION_INT_DIVIDE_BY_ZERO) \ FUN(EXCEPTION_INT_OVERFLOW) \ FUN(EXCEPTION_INVALID_DISPOSITION) \ FUN(EXCEPTION_NONCONTINUABLE_EXCEPTION) \ FUN(EXCEPTION_PRIV_INSTRUCTION) \ FUN(EXCEPTION_SINGLE_STEP) \ FUN(EXCEPTION_STACK_OVERFLOW) #include <setjmp.h> static jmp_buf exception_jumper; static LONG WINAPI VectoredHandler__(struct _EXCEPTION_POINTERS *ExceptionInfo) { PCONTEXT Context; Context = ExceptionInfo->ContextRecord; printf("\n---------------- EXCEPTION ---------------------\n"); DWORD except_code = ExceptionInfo->ExceptionRecord->ExceptionCode; #define FUN(E) if(except_code == E) {printf("Code 0x%x: %s \n", except_code, #E);} else WIN32_EXCEPTION_LIST {printf("UNKNOWN EXCEPTION CODE, wtf!\n");} #undef FUN printf("------------------------------------------------\n\n"); longjmp(exception_jumper, 1); return EXCEPTION_CONTINUE_EXECUTION; } #define TRY_EXCEPT(TRY, EXCEPT) \ { \ PVOID vectored_exhandler; \ vectored_exhandler = AddVectoredExceptionHandler(0,VectoredHandler__); \ if(!setjmp(exception_jumper)) { \ TRY \ } else { \ EXCEPT \ } \ RemoveVectoredExceptionHandler(vectored_exhandler); \ } #define DLL_INVOKE(FUN_NAME, ...) if(FUN_NAME) { \ TRY_EXCEPT( \ {FUN_NAME(__VA_ARGS__);}, \ {FUN_NAME = NULL; \ printf("Culprit: `%s` REMOVED AND TERMINATED! \n\n", #FUN_NAME);} \ ); \ } |
1 | DLL_INVOKE(module->mod_update, delta_time, data); |