c++ - Exiting a program without coredump or Segmentation Faults -
I was wondering if a program without any segfault
or core dump
.
I entered ending ()
and exit ()
and return 0
. They are not all working in my project.
if (it-> board.IC full) ()
exit () / abortion ()
and Likewise, functions are not generally the proper way to end C ++ programs as you have seen, they do not run C ++ Destructors, which opens your file stream. If you really want to use exit ()
, entering a cleanup function with it is a good idea, however, I strongly recommend that you switch to C ++ exceptions instead With exceptions, is called Destroyer and if there is some top level cleaning to be done before the end, then you can catch exceptions like usual on main ()
And after that wrong Normal return with code This code also prevents the dump.
int main () {try methods that can fail and can not be retrieved // // if an error is fatal throwing an exception function (); } Hold (...) {// Return some error code to signal // should end in program form, as was supposed to return -1; } // and this will return a normal / successful return 0; }
Comments
Post a Comment