I have known nested functions are supported as an extension in gcc, but I compile a c file used nested function with an error. Error massage is like this:
test.cpp:6:40: error: function definition is not allowed here double
square (double z) { return z * z; }
And nested function is like this:
foo (double a, double b)
{
double square (double z) { return z * z; }
return square (a) + square (b);
}
My operation system is Mac Os, and version is 10.12.6
When I enter gcc -v
in iTerm2, the response is this:
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.38)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin