the return value is for giving a "hint" to a system that the program was terminated successfully
More than a "hint". It explicitly tells what happened, and that can be quite useful. For instance, when you run a particular program, say, from a different program (think installations), you might need to know what happened, and if it did not go exactly as planned (return 0), maybe your installation program can say oh ok, it returned with value blah, which means blah, so we'll do blah instead to get around it.
So yea, more than a hint, but you seem to be on the right track anyway.
POSIX systems have a little more information attached to the exit code. IIRC, the first 256 values (0..255) are available to you to return an exit code. The remainder of the process exit code is used by the system to provide information about the status of the process. http://linux.die.net/man/2/wait
Some platforms completely ignore the exit code altogether.
Keep in mind that C was designed along with Unix... so the exit code is a fairly *nix-centric thing. Other systems either already had something primitive or have been modified/created with a process exit code simply because it is common/useful. In systems like VMS, for example, playing with exit codes is really obnoxious... er, here's something I dug up http://www.unh.edu/cis/docs/vms-to-unix/Articles/3.02.html
// Is returning a non-zero made for debugging? Like if you coded a safety feature where "if this happens, return 12" then you would see it returned 12 and therefore know where the problem was sort of, for run-time errors maybe?
I don't really get what the discussion is.
People that scream that void main is valid, go read the ISO14882:1998 and 9899:1990.
I have (had to for school), and it's not in it, so it's not valid C or C++.
If I write a compiler that will see aquaman main() as legal C or C++ doesn't make it so, even if every compiler in the world does the same. The only language where void main() is legal that I know of is c# (ISO 23270). (but I only know C based languages, I'm sure there more).
It's not just for debugging, it's also to let a parent process know whether the program was able to successfully finish its job.
It's just a regular error code.
I know what is in it. The return type is implementation-defined, that is why void or any other return type CAN be used in A implementation of C++. But that doesn't mean others will to. Int MUST be implemented in ALL implementations of C++. Keep in mind the ISO is talking about the implementation of C++ itself, not a programmer implementing C++ to write it's program.
Meaning any_Type main () is allowed to be implemented by the compiler, but only int main() is true C++.
(True C and C++ source code is supposed to be implemented independent.)
In C, a conforming implementation may return anything. However, all conforming implementations must support main() returning int. Hence, I agree with your sentiment (as do the vast majority of knowledgeable C veterans) that only int main is proper, because it is portable to all implementations of the standard.
The article I linked you also takes care to show how void main is only legal as a loophole in the wording of ISO/IEC 9899:1999.
completely agree with you Duoas, and sorry I mist the fact about the 1999 and 1990.
Never really looked in to the new standard.
I still think allowing implementation-defined stuff to be in a standard goes agents having a standard.
If we go there we can all forget about implementation independent code and start writing code multiple times to support different implementations or go back to assembler code. Now where is the fun in that xD