Xcode main return value
MacBook Pro, macOS Sierra (10.12.6)
MacBook Pro, macOS Sierra (10.12.6)
All shells (bash, zsh, sh, ksh) reflect a 255 when the exit code is -1 from an executable ObjC, C, or C++ program, or Python, Ruby, etc. This is because shells limit exit codes to 0 thru 255, and -1 is out of range, so is set to 255 by the shell. And the size of an int on X86_64 is 8 bytes as quad_t.
NSLog(@"%ld", sizeof(quad_t));
It is customary to use a return 0; as the final statement in main, and use guard statements prior to this point in your code to determine if an error has occurred, and that an earlier termination is warranted in your main autorelease pool.
OK. I learned something new.
Thanks for your patience.
it is customary to return zero. however, there is nothing wrong with returning -1. When I do return a minus 1 (as shown), then console reports I returned +255. the return type is "int" (a signed value). So how did -1 (a signed, 8-bit value) get returned as 255?
That does not seem correct. Is an int on a 64-bit i7 an 8-bit value?
Xcode main return value