c++ - Terminate application AND call the destructors of local objects -
i have objects on stack in main function:
int main(...) { cfoo foo; cbar bar; } also, have function, keeps track of errors in application:
void err(std::string msg) { somehowlogerrormessage(msg); exit(1); } err function useful when have report fatal error. log error , terminate application - cannot recover after such errors. however, terminating "exit()" not invoke foo , bar destructors - behavior, expected (but wrong). "abort()" doesn't either. also, i cannot use exceptions catch them in main(). there other way implement err function so, terminates app , correctly cleans stack objects? or should somehow redesign error handling?
thanks!
p.s. way, can't send wm_quit message main window? not winapi, app pure win32 , err() function can handle main window. work?
not without exceptions or returning err way callstack. need unwind stack.
Comments
Post a Comment