exited with status huh? (curiosity killed the cat)

Discussion in 'Mac Programming' started by Darkroom, May 26, 2008.

  1. Darkroom Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #1
    so i'm doing some beginner code stuff with NSLog() function and i've noticed something particular:

    Code:
    int main()
    {
    	int x = 8;
    	float y = 10.5;
    	float z = x * y;
        NSLog (@"iMac calculates that %d * %.1f = %.0f", x, y, z);
    	return 10000;
    }
    
    log returns:

    Code:
    2008-05-26 05:46:04.041 nothing[1672:10b] iMac calculates that 8 * 10.5 = 84
    
    The Debugger has exited with status 16.The Debugger has exited with status 16.
    
    so why does "return 10,000;" exit with status 16? and "return 112541233;" exit with status 49? etc?
     
  2. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #2
    Why are you even returning these values in the main function anyway? It should return 0 for success or if you hit some error handling code return -1 for failure.
     
  3. Darkroom thread starter Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #3
    right, well as i mentioned i was just curious... but thanks for asking... :rolleyes:
     
  4. Palad1 macrumors 6502a

    Palad1

    Joined:
    Feb 24, 2004
    Location:
    London, UK
    #4
    10000 decimal is also 0x2710

    I think the return code is bitmasked with 0x00FF, 0x00FF being the 'user' part of the return code. Hence the exit code of 16. [0x10]

    Cheers,
    Palad1
     
  5. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #5
    Eh? I was asking a question in the hopes of trying to help. No need to get defensive about it.
     
  6. Darkroom thread starter Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #6
    sorry, i've been up all night... i was just curious to be honest, i knew i wasn't suppose to write "return 10000", i just did, and put other numbers in and it gave strange results...
     

Share This Page