当前位置:网站首页>Several keywords in C language
Several keywords in C language
2022-07-02 05:49:00 【Croxd】
auto: Automatic local variables , Generally, when we define local variables , Namely auto local variable , But omitting it when we write has the same effect , Local variables are stored on the stack .
extern: Life global variable . For example, I a.c Can be defined in int a, b.c I want to call This a But it's not defined , At this time b.c You need to use this a Before the variable , use extern a, To tell a It is defined in other files , You can use it .
static: There are two uses , The first is to modify local variables , It is called static local variable . Static local variables are the same as assigned global variables , Save in data segment , The life cycle is the same . His connection is connectionless .
The second is to modify global variables or modify functions , It turns external links into internal connection properties , Can only be used in this document , Don't want to be called by other files . External connection attributes are ordinary functions and global variables , Connectionless attributes are local variables and static local variables .
register: It is generally used to decorate global variables that are often called . Will put it in the register , For example uboot Medium gd Global variables , Such benefits can improve efficiency . But he tried to put it in the register , Instead of necessarily putting it in the register .
volatile: Variable , Changeable . There are three cases where the value of a variable is unknown ,1. Interrupt the changed value ,2. The same variable used in multithreading ,3. Value of hardware change ( register ), All three compilers cannot know the change of value . So it is used to tell the compiler when it encounters this variable , Don't optimize this variable . So there will be no errors .
const: Often used to define constants , Indicates that this constant cannot be modified . It mainly depends on const Which is the nearest behind , Is to decorate which , near * The value cannot be modified , Close to the variable is the address, which cannot be modified .
- const int * a: Constant pointer , The value cannot be modified , The address pointed to can be modified .
- int * const a: constant pointer , Value can be modified , The address pointed to cannot be modified .
边栏推荐
- Online music player app
- Reflection of the soul of the frame (important knowledge)
- I want to understand the swift code before I learn it. I understand it
- [personal test] copy and paste code between VirtualBox virtual machine and local
- Determine whether there is an element in the string type
- all3dp.com网站中全部Arduino项目(2022.7.1)
- 小程序跳装到公众号
- Straighten elements (with transition animation)
- Lantern Festival gift - plant vs zombie game (realized by Matlab)
- Zzuli:1060 numbers in reverse order
猜你喜欢
随机推荐
Determine whether there is an element in the string type
php获取cpu使用率、硬盘使用、内存使用
2022-2-14 learning xiangniuke project - Section 6 displays login information
软件测试基础篇
Fabric. JS upload local image to canvas background
Visual Studio導入
ThreadLocal memory leak
“簡單”的無限魔方
小程序跳装到公众号
Vscode paste image plugin saves image path settings
File contains vulnerability (I)
RNN recurrent neural network
Brew install * failed, solution
Visual studio import
文件包含漏洞(二)
php内的addChild()、addAttribute()函数
all3dp.com网站中全部Arduino项目(2022.7.1)
Zzuli: maximum Convention and minimum common multiple
软件测试 - 概念篇
Fabric. JS background is not affected by viewport transformation









