I am trying a small example to know about the static external variable and its uses. The static variable is of local scope and the external variable is of global scope.
Remember this (quoting Eli Bendersky):
- A static variable inside a function keeps its value between invocations.
- A static global variable or a function is "seen" only in the file it's declared in
In your code, static int m = 25;
means that m
's scope is limited only to that file, that is, it is only visible inside static5.c
and nowhere else.
If you would like to make use of m
outside of static5.c
make sure to remove the keyword static
from the declaration of the variable.
For a more canonical explanation, along with an example, see this answer by Eli Bendersky
EDIT: (according to Klas' recommendation) **The actual scope is a compilation unit, not the source file. The compilation unit is the way the file looks after the preprocessor step