static here have a different meaning. For functions it means the identifier fun won't be exported (the function is local to the module).
main and foo are exported (made extern).
In this example all bytes for the functions are encoded in .text section.
Why this is useful? Take a look at this:
Code:// test1.c #include <stdio.h> extern void g( void ); static void f( void ) { puts( "I'm f() from test1.c" ); } int main( void ) { f(); g(); return 0; }Code:// test2.c #include <stdio.h> static void f( void ) { puts( "I'm f() from test2.c" ); } void g( void ) { f(); } // calls the module local f().Different functions with the same name in different modules.Code:$ cc -O2 -c *.c $ cc -s -o test test1.o test2.o $ ./test I'm f() from test1.c I'm f() from test2.c
PS: The functions declarations with () are wrong, in C. Modern compilers allows it, but the correct way to declare is:
Otherwise, this code is C++, not C.Code:int main( void ) // void is necessary! { ... }