Defining a nested function (i.e. inside another function) is valid, the only limitation is that the former function's scope is limited by the enclosing function. It's just like defining a local variable. You can find more information here: http://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html