// License: "Code is yours. Take it. Rape it. It's yours." #ifndef _EXIT_HPP #define _EXIT_HPP struct _ProgramExitException { int returnCode; _ProgramExitException(int returnCode) : returnCode(returnCode) {} }; #define exit(returnCode) throw _ProgramExitException(returnCode); // funguje pouze pro "int main(int,char**)" // jednoduché přepsat pro jinou formu funkce main #define main(a,b) \ _falseMain(int argc, char** argv); \ int main(int argc, char** argv) { \ try { \ return _falseMain(argc,argv); \ } \ catch (_ProgramExitException& ex) { \ return ex.returnCode; \ } \ return 0; \ } \ int _falseMain(a, b) #endif /* _EXIT_HPP */