当前位置:网站首页>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 .
边栏推荐
猜你喜欢
Installation du tutoriel MySQL 8.0.22 par centos8
[PHP是否安装了 SOAP 扩]对于php实现soap代理的一个常见问题:Class ‘SoapClient‘ not found in PHP的处理方法
Vscode paste image plugin saves image path settings
PHP development and testing WebService (soap) -win
Cambrian was reduced by Paleozoic venture capital and Zhike shengxun: a total of more than 700million cash
Software testing learning - day 4
RGB infinite cube (advanced version)
OLED12864 液晶屏
Fabric. JS upload local image to canvas background
Conglin environmental protection rushes to the scientific and Technological Innovation Board: it plans to raise 2billion yuan, with an annual profit of more than 200million yuan
随机推荐
1037 Magic Coupon
Applet jumps to official account
1036 Boys vs Girls
Zzuli:1069 learn from classmate Z
kmp思想及模板代码
460. LFU 缓存 双向链表
Visual Studio導入
如何写出好代码 — 防御式编程指南
Grbl software: basic knowledge of simple explanation
460. LFU cache bidirectional linked list
Software testing - concept
15 C language advanced dynamic memory management
LCD之MIPI协议的一些说明
Matplotlib double Y axis + adjust legend position
all3dp.com网站中全部Arduino项目(2022.7.1)
2022-2-14 learning xiangniuke project - Section 7 account setting
H5 jump applet
Fabric. JS basic brush
Determine whether there is an element in the string type
Cambrian was reduced by Paleozoic venture capital and Zhike shengxun: a total of more than 700million cash