Xcode 3.2.1 Fnested Functions

6 replies [Last post]
aviationalyours
aviationalyours's picture
Title: NooBot+
Joined: 01/21/2010
Posts:
BotPoints: 13
User offline. Last seen 1 year 42 weeks ago.

Dear Forum,

I have KISS-C 2.2.1 and Xcode 3.2.1 (both 64-bit) installed on my Snow Leopard MacBook Pro. I wrote a program that contains many other functions, according to the way we did it during the Botball workshop. When I attempt to compile, it gives me the error "error: nested functions are disabled, use -fnested-functions to re-enable".

From googling it has become apparent that nested functions have been disabled with the new Xcode released by Apple, as it was causing some sort of thread bug. I have limited knowledge of programming, so I don't really understand nested functions. However, when I tried the code on a PC, it compiled without any trouble.

I am in the process of testing this on another Mac and directly on the CBC. Any ideas?

P.S. Kindly note that I did not attach the code as it is one of our Botball competition programs.

aviationalyours
aviationalyours's picture
Title: NooBot+
Joined: 01/21/2010
Posts:
BotPoints: 13
User offline. Last seen 1 year 42 weeks ago.

Update: We just tested this on another MacBook Pro with the exact same software. The problem is persistent.

Thanks,
Abdullah

Jeremy Rand
Jeremy Rand's picture
Title: Botball Youth Advisory Council
Joined: 04/03/2009
Posts:
BotPoints: 634
User offline. Last seen 15 hours 32 min ago.

I don't know how to fix this on the MacBook Pro, but I strongly suspect that compiling on the CBC-side will fix this. You can either use a flash drive to do this, or you might try WiFi downloads using the Norman/Nease Mods. Thing is, the Norman/Nease Mods were never tested on a Mac; we only had Windows and Linux available to test. I assume that getting them to work with Macs would be easy though.

If you figure anything out or find a workaround that works well for you, please let us know! :-)

-Jeremy Rand
Senior Programmer, Norman Advanced Robotics (2010-2011), Norman High (2008-2009), Norman North (2005-2007), Whittier Middle School (2003-2004)
2011 President, Botball Youth Advisory Council (2009-2011)

aviationalyours
aviationalyours's picture
Title: NooBot+
Joined: 01/21/2010
Posts:
BotPoints: 13
User offline. Last seen 1 year 42 weeks ago.

Problem solved... Apparently the program can only take 6 functions apart from the main function. We had 7.

Jeremy Rand
Jeremy Rand's picture
Title: Botball Youth Advisory Council
Joined: 04/03/2009
Posts:
BotPoints: 634
User offline. Last seen 15 hours 32 min ago.

Glad you figured it out. That is quite weird though... you might want to contact KIPR tech support about this; having a limit of 6 functions is pretty restrictive.

-Jeremy Rand
Senior Programmer, Norman Advanced Robotics (2010-2011), Norman High (2008-2009), Norman North (2005-2007), Whittier Middle School (2003-2004)
2011 President, Botball Youth Advisory Council (2009-2011)

matthewbot
matthewbot's picture
Title: YAC
Joined: 04/12/2009
Posts:
BotPoints: 94
User offline. Last seen 1 year 30 weeks ago.

Nested functions are when you declare a new function inside of another one, like this:

  1. void main() {
  2. printf("Hello ");
  3. void func() {
  4. printf("World\n");
  5. }
  6.  
  7. func();
  8. }

They're a nonstandard C extension that almost nobody uses. You may not have done this intentionally, but try indenting your program and double checking all of your brackets to be sure you have completely closed one function before starting the next. Or you can post your code here. Xcode does not have a limit on the number of functions you can have. I suspect you just deleted the code containing a nested function and the error went away.

--
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction.

Albert Einstein

Project Quadcopter: http://quadcopter.wordpress.com/

aviationalyours
aviationalyours's picture
Title: NooBot+
Joined: 01/21/2010
Posts:
BotPoints: 13
User offline. Last seen 1 year 42 weeks ago.

Yup... I just reviewed the old code and that seems to be it. I added the code from the function without a final closing bracket to another function, hence solving the problem.

Thanks for the help :)