可能重复:
嵌套函数在gcc中是坏事吗?
据我所知,C不允许在其他函数中定义函数.但是以下代码在gcc中编译并运行时没有任何错误.有人可以解释原因吗?另见:http://ideone.com/AazVK
#include <stdio.h>
void val1( int x )
{
void sig( int x ) {
printf("%d\n",x*10);
}
sig(x);
}
int main()
{
void val2(int x) {
x = x*10;
val1(x);
printf( "%d\n", x );
if ( x < 10000 ) {
val2(x);
}
}
val2(20);
return 0;
}
Run Code Online (Sandbox Code Playgroud) c ×1