Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Hexatron

macrumors newbie
Original poster
Nov 18, 2007
2
0
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?
 

autorelease

macrumors regular
Oct 13, 2008
144
0
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.

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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.