< cpp‎ | utility‎ | program
Revision as of 12:36, 2 November 2012 by P12bot (Talk | contribs)

Template:ddcl list begin <tr class="t-dsc-header">

Defined in header <cstdlib>

<td></td> <td></td> <tr class="t-dcl-sep"><td></td><td></td><td></td></tr>

<tr class="t-dcl ">

<td >
[[noreturn]] void exit( int exit_code );

<td class="t-dcl-nopad"> </td> <td > (since C++11) </td> </tr> <tr class="t-dcl-sep"><td></td><td></td><td></td></tr>

<tr class="t-dcl ">

<td >
             void exit( int exit_code );

<td class="t-dcl-nopad"> </td> <td > (until C++11) </td> </tr> Template:ddcl list end

Causes normal program termination to occur.

Several cleanup steps are performed:

  • destructors of objects with thread local storage duration are called
  • destructors of objects with static storage duration are called
  • functions passed to std::atexit are called. If an exception tries to propagate out of any of the function, std::terminate is called
  • all C streams are flushed and closed
  • files created by std::tmpfile are removed
  • control is returned to the host environment. If exit_code is EXIT_SUCCESS, an implementation-defined status, indicating successful termination is returned. If exit_code is EXIT_FAILURE, an implementation-defined status, indicating unsuccessful termination is returned. In other cases implementation-defined status value is returned.

Destructors of variables with automatic storage durations are not called.



exit_code - exit status of the program

Return value



See also

causes abnormal program termination (without cleaning up)
(function) [edit]
registers a function to be called on std::exit() invocation
(function) [edit]
causes normal program termination without completely cleaning up
(function) [edit]