PDA

View Full Version : GCC: Enabling nested functions




Hexatron
Feb 18, 2009, 02:56 AM
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
Feb 18, 2009, 03:23 AM
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.

pstoehr
Feb 18, 2009, 03:41 AM
Hi,

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?

gcc -fnested-functions <yourfile>

might be the solution.

Best regards
Peter