GCC: Enabling nested functions

Discussion in 'Mac Programming' started by Hexatron, Feb 18, 2009.

  1. macrumors newbie

    Joined:
    Nov 18, 2007
    #1
    Hey,

    I'm working my way through a book about learning C and I'm trying to compile code with nested functions. I understand that these have been disabled for a security reason since the switch to Intel, but apparently they can be re-enabled.

    Everything I've found tells me to "use -fnested-functions" and change something with CFLAGS to enable the nested functions in GCC.

    I don't know how I go about doing this.
    What can I do in Terminal to enable nested functions?
     
  2. macrumors regular

    Joined:
    Oct 13, 2008
    Location:
    Achewood, CA
    #2
    You pass -fnested-functions as an argument to gcc. It's not a part of gcc you 'enable,' it's an option you specify when compiling your program.

    Code:
    $ gcc -fnested-functions -o prog prog.c
    
    If you're using Xcode, add -fnested-functions to 'Other C Flags' in the Build tab of Project Info.
     
  3. macrumors member

    Joined:
    Aug 5, 2003
    Location:
    Scheßlitz, Oberfranken, Bavaria, Germany
    #3
    Hi,

    gcc -fnested-functions <yourfile>

    might be the solution.

    Best regards
    Peter
     

Share This Page