当前位置:网站首页>C语言函数之可变参数原理:va_start、va_arg及va_end
C语言函数之可变参数原理:va_start、va_arg及va_end
2022-07-06 09:16:00 【薇远镖局】
|
|
* 输出参数ap(类型为va_list): 用于保存函数参数列表中可变参数的首指针(即,可变参数列表)
* 输入参数A: 为函数参数列表中最后一个固定参数
* 输入参数ap(类型为va_list): 可变参数列表,指向当前正要处理的可变参数
* 输入参数T: 正要处理的可变参数的类型
* 返回值: 当前可变参数的值
|
另一个比较实用的例子:printk只能在内核初始化完控制台(console_init)后才能使用。因此,在Linux内核初始化控制台前,只能使用其它函数来打印内核消息。这些函数有:
|
这些函数都是用汇编实现的,并直接从低层操作s3c2410的串口,并显示信息。因此不需要等到console_init后就可以显示信息。
为了使用这些函数,需要特性的内核选项支持:make menuconfig
Kernel hack ->
[*]Kernel low-level debugging functions
[*]Kernel low-level debugging messages via S3C UART
(0)S3C UART to use for low-level debug
但是,这些函数并没有printk功能那么强大,支持可变参数,支持格式化字符串。为了在Linux内核初始化控制台前,能使用了一个类似于printk的函数,我们将printascii函数封装到新函数debug里:
|
边栏推荐
- ToggleButton实现一个开关灯的效果
- Wangeditor rich text reference and table usage
- 2020 WANGDING cup_ Rosefinch formation_ Web_ nmap
- Detailed explanation of nodejs
- FTP file upload file implementation, regularly scan folders to upload files in the specified format to the server, C language to realize FTP file upload details and code case implementation
- Gallery之图片浏览、组件学习
- 使用LinkedHashMap实现一个LRU算法的缓存
- Solution to the practice set of ladder race LV1 (all)
- 互聯網協議詳解
- 分布式节点免密登录
猜你喜欢

分布式節點免密登錄
![[Blue Bridge Cup 2017 preliminary] grid division](/img/e9/e49556d0867840148a60ff4906f78e.png)
[Blue Bridge Cup 2017 preliminary] grid division

R & D thinking 01 ----- classic of embedded intelligent product development process

Integration test practice (1) theoretical basis

Pytoch Foundation

小L的试卷

Vs2019 use wizard to generate an MFC Application

MongoDB

Machine learning -- decision tree (sklearn)

Mtcnn face detection
随机推荐
yarn安装与使用
Valentine's Day flirting with girls to force a small way, one can learn
sklearn之feature_extraction.text.CountVectorizer / TfidVectorizer
Gallery之图片浏览、组件学习
Word typesetting (subtotal)
wangeditor富文本引用、表格使用问题
wangeditor富文本组件-复制可用
Mysql的索引实现之B树和B+树
Detailed explanation of nodejs
【Flink】CDH/CDP Flink on Yarn 日志配置
vs2019 使用向导生成一个MFC应用程序
Basic use of pytest
L2-007 family real estate (25 points)
物联网系统框架学习
互聯網協議詳解
ES6 let and const commands
【presto】presto 参数配置优化
【flink】flink学习
5G工作原理详解(解释&图解)
Nodejs connect mysql