I was recently coding in C++ when I realized that the int main()
function works fine as a long main()
and can support larger numbers (up to 2^63) so why is that not the normal way it is coded?
Asked
Active
Viewed 40 times
0
-
1That's by definition the signature of an executable entry point, and supported by a variety of OS like this. If you want to get program output of any kind, use output streams. – πάντα ῥεῖ May 04 '21 at 19:40
-
2Do you really need more than 2^32 different return codes? Normally you return EXIT_SUCCESS or EXIT_FAILURE indicating to the calling process success or failure – drescherjm May 04 '21 at 19:53
-
And even `int` is already too much for some OS. Typically, on those OS, you can only use error code from 0 to 255, so a single `uint8_t`. – prapin May 04 '21 at 21:00