gcc supports a Pascal-like extension for C, namely nested functions like
#include <stdio.h>
int main(void)
{
int a = 1, b = 2;
void foo(void)
{
printf("%s: a = %d, b = %d\n", __FUNCTION__, a, b);
}
printf("%s: a = %d, b = %d\n", __FUNCTION__, a, b);
foo();
return 0;
}
Compile this with -nested-functions:
$ gcc -Wall --nested-functions nested.c -o nested
:
$./nested
main: a = 1, b = 2
foo: a = 1, b = 2
, , gcc , .