I'm familiar with several uses for the keyword "static" in C:
- Static variables within a function will maintain their value between function calls.
- Static (global) variables in a file cannot be accessed outside the file they're declared in.
- Static functions cannot be accessed outside the file they're declared in.
- This obscure use as part of an array type declaration as an argument to a function.
The first use has to do with an entity's lifetime, the second and third uses have to do with an entity's visibility, the fourth use has to do with optimization, and it seems strange to me that one keyword would act so differently depending on where it is used. Is there some strange detail of how static is usually implemented in compilers that makes it easy for this one keyword to do all of the above? What is the underlying functionality that "static" provides which results in these varied behaviors?