GCC: Enabling nested functions

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

  1. Hexatron
    Expand Collapse
    macrumors newbie

    Nov 18, 2007

    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. autorelease
    Expand Collapse
    macrumors regular

    Oct 13, 2008
    Achewood, CA
    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.

    $ 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. pstoehr
    Expand Collapse
    macrumors member

    Aug 5, 2003
    Scheßlitz, Oberfranken, Bavaria, Germany

    gcc -fnested-functions <yourfile>

    might be the solution.

    Best regards

Share This Page