For example...
#include <iostream>
using namespace std;
int main(){return 300;}
Returns:
Process finished with exit code 44
??
The standard knows only two standaradized return values: EXIT_SUCCESS
(or zero) and EXIT_- FAILURE
:
3.6.1/5 A return statement in main has the effect of leaving the main function (destroying any objects with automatic storage duration) and calling
std::exit
with the return value as the argument.18.5/8 (...) Finally, control is returned to the host environment. If status is zero or
EXIT_SUCCESS
, an implementation-defined form of the status successful termination is returned. If status isEXIT_- FAILURE
, an implementation-defined form of the status unsuccessful termination is returned. Otherwise the status returned is implementation-defined.
It is hence not guaranteed that any other integer is returned as is.
On MS Windows for example, the GetExitCodeProcess()
function returns the integer value so you'll get 300.
On POSIX compliant systems, like Linux, the rule is that ("only the 8 least significant bits (i.e. status & 0377) shall be available to the awaiting parent process"). So for 300, it will be 44.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With