Is it intended that the GCC C compiler support nested functions?
I would like to know so that I can determine whether to file bug reports
against other projects for nested function use.

---- Begin Nested Function example
    void foo(void) {
      void bar(void) {
        puts("Bar");
      }

      puts("Foo");
      bar();
    }
---- End Nested Function example
 
The last I heard, the ANSI (ISO) C language specification prohibited nested
functions.  I have been looking at the code for GRUB, another GNU project, and
noticed that there are several instances of nested functions.  I asked one of
the maintainers of GRUB and received the following response which implies that:
    1) the GCC C compiler is intended to support nested functions
    2) Grub (and possibly other GNU projects) are written in "GNU C" and not
       intended to be compiled with other compilers.

---- Begin Quote
  > 2) grub/asmstub.c :: grub_stage2()
  >         This function knowingly uses a nested function.  Nested
  >         functions are prohibited by the ISO-C and C++ language
  >         specifications.  Conformant compilers will blow up.
 
  It seems that grub is written in GNU C, not ISO-C. So it is not intended
  to be compiled by other compilers. There is many nested functions used
  in grub source code. So, don't worry about that.
---- End Quote

Thank You,
Daryl McDaniel 
SSG/SSD/Platform Software Infrastructure 
JF1-235 
+1 503-712-4670 
  
Simple clear purpose and principles give rise to complex and intelligent 
behavior. 
Complex rules and regulations give rise to simple and stupid behavior. 
-- Dee Hock 
  

Reply via email to