今天在研究怎么获取 linux 系统上 pci 设备相关的信息的时候,发现了 pciutils 这个工具(以后再讲这个工具)。然后打开 github,下载源码,打开 vscode,一套行云流水。
一看目录结构和 LICENSE,是个标准的 GNU 项目,GNU 项目一般使用getopt
解析参数。
打开源码一看,这个 options 参数有点奇怪,源码:/pciutils/lspci.c
1 |
|
这个 options 初始化有点奇怪,后面的宏定义是什么意思?源码:/pciutils/pciutils.h
1 |
|
后面的宏定义是根据不同的编译选项,选择支持某些 options。如果 define 了 GENERIC_OPTIONS 那么就添加“A:GO:”等等。将宏定义解开来就是这个形式:
1 |
|
C 中还可以这样初始化字符串?!!我查找了一些资料,但是并没有找到相关的内容,所以这么无聊的问题我也写出来放到博客里:)。
个人猜测这个应该是编译器进行的优化,它并不会解释成this is string1" "and" "this is string2
而是将几段字符串拼接了起来”this is string1andthis is string2”。
1 |
|
在函数中也同样可以使用,看来和 java 的+
相似,具体的情况等以后深入使用再说。