One, several modifier keywords
Global variables:
Global variables are divided into declarations and implementations as well as functions. If it is a global variable, the implementation will need to be declared before it is called.
Note: The declaration of a global variable can only be written outside the function, and the function is not a global variable but a local variable.
Static
To modify a local variable:
You can change a local variable to a static variable. This means: When the program starts loading, the program exits to reclaim space (much like a global variable).
Static variable: a local variable modified with static is called a static variable.
To modify a global variable:
Make the global variable accessible only in this module.
Modifier functions:
modifier function, it can only be accessed in this module.
extern
Local variables cannot be decorated.
To modify a global variable:
Allows global variables to be accessed in all modules.
Modifier functions:
The extern modifier function, which is accessible on behalf of all modules. It is the default (not write is extern)
The following two can only be used to modify a local variable.
Auto (Know): The default, to the system to automatically manage memory (in the stack), is when to open, when recycling, system management.
Register (Understanding): Adds a variable to the register. The register is the place where the CPU temporarily saves data, the characteristic is: very fast, but the capacity is small, the cost is Jin GUI, so can save very little data.
Post-compilation era, which means that the compiler will automatically compile the code for you to optimize, the compiler can help you determine when to use auto, when the Register
Second, memory partition
Stack area: All local variables are automatically managed by the system, and the scope is recycled
Heap Area: Programmers themselves apply for space, are in the heap area, the programmer himself to maintain the recycling
Global zone: All global variables and static variables, the program starts to open, the program exits before recycling
BSS segment and data segment
The BSS segment holds all uninitialized global variables and static variables (just a record of how big the record is)
The data segment holds all the initialized global variables and static variables
Constant area: Rodata segment. is all the constants. Text Constants (strings), programs start on the open, program exit to recover
Code area: is the compiled binary code. The program starts to open, and the program exits before it is recycled
Text segment
From the top down, the address is from high to low
Just remember: Each area is placed in a separate thing.
Introduction to the basic knowledge of C language Learning (18): Several modifier keywords and memory partitions