(1) What is the difference between a static global variable and a normal global variable?
(2) What is the difference between static local variables and ordinary local variables?
(3) What is the difference between the static function and the normal function scope?
(4) What is the difference between a static function and a normal function?
(1) What is the difference between a static global variable and a normal global variable?
A: The description of the global variable is then static, which makes it a global variable. Global variables themselves are static storage, and static global variables are, of course, static storage methods. The two are not different in how they are stored. The difference between the two is that the scope of the non-static global variable is the whole source program, when a source program consists of multiple source files, non-static global variables are valid in each source file. A static global variable restricts its scope, which is valid only within the source file that defines the variable, and cannot be used in other source files of the same source program. Because the scope of a static global variable is limited to one source file, it can be common only for functions within that source file, so you avoid causing errors in other source files. From the above analysis, it can be seen that changing the local variable to a static variable changes its storage mode, which changes its life time. Changing a global variable to a static variable changes its scope and limits its scope of use.
(2) What is the difference between static local variables and ordinary local variables?
A: The static local variable is initialized only once, the next time based on the last result value;
(3) What is the difference between the static function and the normal function scope?
Answer: Only in this document. Functions that are used only in the current source file should be described as intrinsic (static) and intrinsic functions should be described and defined in the current source file. For functions that can be used outside of the current source file, it should be stated in a header file that the source file to use these functions should contain the header file.
(4) What is the difference between a static function and a normal function?
A: The static function has only one copy in memory, and the normal function maintains a copy of the program's local variables in the (stack) in each call, the global variable exists in the (static zone), and the dynamic requisition data is present in the (heap).
The difference between a static global variable and a normal global variable