Nested function in C

Sachin Chourasiya picture Sachin Chourasiya · Apr 9, 2010 · Viewed 82.6k times · Source

Can we have a nested function in C? What is the use of nested functions? If they exist in C does their implementation differ from compiler to compiler?

Answer

James McNellis picture James McNellis · Apr 9, 2010

You cannot define a function within another function in standard C.

You can declare a function inside of a function, but it's not a nested function.

gcc has a language extension that allows nested functions. They are nonstandard, and as such are entirely compiler-dependent.