C 关键字

C reserved keywords

存储类型说明符 storage-class specifier

keywordsmeaning
autoautomatic duration storage-class specifier with no linkage
externstatic duration storage-class specifier with either internal or more usually external linkage
registerautomatic duration storage-class specifier with no linkage. Hints that the variable will be used heavily
staticstatic duration storage-class specifier with internal linkage at file scope and no linkage at block scope
static array indices in function parameter declarations (since C99)

跳转, 条件, 循环语句声明符 statement declarator

keywordsmeaning
break
continue
goto
return
ifif statement
elseif statement: alternative branch
switchswitch statement
caseswitch statement: case labels
defaultswitch statement: efault case label
type-generic expression: as the declaration of the default generic association(since C11)
dodo-while loop
forfor loop
whilewhile loop
do-while loop: terminating condition of the loop

类型声明符 type declarator

keywordsmeaning
char
int
double
enumenumeration type
float
inlineinline function specifier
structcompound type
union
typedef
voidincomplete type
in a function with no parameter or no return value

类型修饰符 type modifier

keywordsmeaning
longlong type modifier
shortshort type modifier
signedsigned type modifier
unsignedunsigned type modifier

类型限定符 type qualifier

keywordsmeaning
constconst type qualifier
restrictrestrict type qualifier
volatilevolatile type qualifier

操作符 operator

keywordsmeaning
sizeofsizeof operator

inline

  1. 使用 inline 关键字声明内联函数 Inline function, 内联函数在某些情况下类似于宏, 直接将代码内嵌到调用它的父函数中
  2. 编译时需要指定优化等级为 -O3 才能被内嵌, 也可以指定内嵌函数属性 #pragma always_inline 强制内嵌
  3. 使用 ISO C 标准的时候,可以使用 __inline__ 关键字代替 inline 关键字

有几种情况将不内嵌,而作为普通函数调用:

  1. 可变参数的函数
  2. 调用 alloca 类库的函数
  3. 有可变尺寸数组声明的函数
  4. 非本地 goto 的函数
  5. 嵌套调用的函数

const

  1. 使用 const 限定符修饰形参可以防止函数修改传入的参数
  2. 使用 const 限定符修饰指针和引用

参考

  1. cppreference
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值