00001 #ifndef __FINALIZE_H__ 00002 #define __FINALIZE_H__ 00003 00007 00008 #include <stdio.h> 00009 00010 #ifdef __cplusplus 00011 extern "C" { 00012 #endif 00013 00014 #define FUNCTION_INIT_VARS_VOID int __function_return_void_missing 00015 00016 #define FUNCTION_INIT_VARS(type) type __return_variable 00017 00018 #define RETURN_VALUE __return_variable 00019 00020 #define RETURN_VOID goto _finalize_label 00021 00022 #define RETURN(val) \ 00023 do { __return_variable = val; goto _finalize_label; } while(0) 00024 00025 #define FUNCTION_BODY 00026 00027 #define FUNCTION_FINALIZE \ 00028 fprintf(stderr, \ 00029 "Earny Funtion Macro Did Not Return: line %d, file \"%s\"\n", \ 00030 __LINE__, __FILE__); \ 00031 exit(1); \ 00032 _finalize_label: 00033 00034 #define FUNCTION_RETURN_VOID __function_return_void_missing = 0 00035 00036 #define FUNCTION_RETURN return __return_variable 00037 00038 #ifdef __cplusplus 00039 } 00040 #endif 00041 00042 #endif