Nested functions are disabled

Discussion in 'iOS Programming' started by myvsiac, Jan 28, 2010.

  1. myvsiac macrumors newbie

    Jan 28, 2010
    Hi. I'm new at programming. I bought an objective -c book and I just followed the book. I don't know why I get three errors. Help!

    #import <Foundation/Foundation.h>
    // returns NO if the two intergers have the same
    // value, YES otherwise
    BOOL areIntsDifferent (int thing1, int thing2)
    	if (thing1 == thing2) {
    		return (NO);
    	} else {
    		return (YES);
    	} // areIntsDifferent
    // given a YES value, return the human-readable
    // string "YES". Otherwise return "NO"
    NSString *boolString (BOOL yesNo)
    	{ *Nested functions are disabled, use -fnested-functions to re-enable*
    		if (yesNo == NO) {
    			return (@"NO");
    		} else {
    			return (@"YES");
    	} // boolString
    int main (int argc, const char *argv[])
    	{ *Nested functions are disabled, use -fnested-functions to re-enable*
    		BOOL areTheyDifferent;
    		areTheyDifferent = areIntsDifferent (5, 5);
    NSLog (@"are %d and %d different? %@",
    	   5, 5, boolString(areTheyDifferent));
    		areTheyDifferent = areIntsDifferent (23, 42);
    NSLog (@"are %d and %d different? %d",
    	   23, 42, boolString(areTheyDifferent));
    	} // main *Expected declaration or statement at end of input*
    I got two nested functions error and one expected declaration error.

    Help me, please!
  2. xsmasher macrumors regular


    Jul 18, 2008
    You'll kick yourself - you're missing the closing bracket for the areIntsDifferent function. The compiler thinks you're trying to define the other functions inside areIntsDifferent.
  3. myvsiac thread starter macrumors newbie

    Jan 28, 2010
    Thank you!
    I couldn't see it!

Share This Page