差之毫厘,谬以千里
今天在編一段代碼的時候,遇到一個很奇怪的報錯:
In file included from include/asm-generic/int-ll64.h:10:0,from /home/charles/code/linux-3.10.28/include/uapi/asm-generic/types.h:7,from arch/arm/include/generated/asm/types.h:1,from include/uapi/linux/types.h:4,from include/linux/types.h:5,from include/linux/list.h:4,from include/linux/module.h:9,from /home/charles/code/modules/testproc.c:5: include/uapi/asm-generic/int-ll64.h:19:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'typedef'typedef __signed__ char __s8;^ In file included from include/linux/list.h:4:0,from include/linux/module.h:9,from /home/charles/code/modules/testproc.c:5: include/linux/types.h:98:1: error: unknown type name '__s8'typedef __s8 int8_t;^ In file included from include/linux/quota.h:42:0,from include/linux/fs.h:245,from include/linux/proc_fs.h:8,from /home/charles/code/modules/testproc.c:6: /home/charles/code/linux-3.10.28/include/uapi/linux/dqblk_xfs.h:51:2: error: unknown type name '__s8'__s8 d_version; /* version of this structure */^ /home/charles/code/linux-3.10.28/include/uapi/linux/dqblk_xfs.h:52:2: error: unknown type name '__s8'__s8 d_flags; /* FS_{USER,PROJ,GROUP}_QUOTA */^ /home/charles/code/linux-3.10.28/include/uapi/linux/dqblk_xfs.h:153:2: error: unknown type name '__s8'__s8 qs_version; /* version number for future changes */^ /home/charles/code/linux-3.10.28/include/uapi/linux/dqblk_xfs.h:155:2: error: unknown type name '__s8'__s8 qs_pad; /* unused */
In file included from include/asm-generic/int-ll64.h:10:0,from /home/charles/code/linux-3.10.28/include/uapi/asm-generic/types.h:7,from arch/arm/include/generated/asm/types.h:1,from include/uapi/linux/types.h:4,from include/linux/types.h:5,from include/linux/list.h:4,from include/linux/module.h:9,from /home/charles/code/modules/testproc.c:5: include/uapi/asm-generic/int-ll64.h:19:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'typedef'typedef __signed__ char __s8;^ In file included from include/linux/list.h:4:0,from include/linux/module.h:9,from /home/charles/code/modules/testproc.c:5: include/linux/types.h:98:1: error: unknown type name '__s8'typedef __s8 int8_t;^ In file included from include/linux/quota.h:42:0,from include/linux/fs.h:245,from include/linux/proc_fs.h:8,from /home/charles/code/modules/testproc.c:6: /home/charles/code/linux-3.10.28/include/uapi/linux/dqblk_xfs.h:51:2: error: unknown type name '__s8'__s8 d_version; /* version of this structure */^ /home/charles/code/linux-3.10.28/include/uapi/linux/dqblk_xfs.h:52:2: error: unknown type name '__s8'__s8 d_flags; /* FS_{USER,PROJ,GROUP}_QUOTA */^ /home/charles/code/linux-3.10.28/include/uapi/linux/dqblk_xfs.h:153:2: error: unknown type name '__s8'__s8 qs_version; /* version number for future changes */^ /home/charles/code/linux-3.10.28/include/uapi/linux/dqblk_xfs.h:155:2: error: unknown type name '__s8'__s8 qs_pad; /* unused */
這些報錯完全是在內核代碼里的,查了半天也沒找出問題。。
后來看了下自己的代碼,發現在一個注釋行開頭,多了個字母 i...
<strong><span style="color:#FF0000;">i</span></strong>/*This program is used to allocate memory in kernel and pass the physical address to userspace through proc file.*/#include <linux/version.h> #include <linux/module.h> #include <linux/proc_fs.h> #include <linux/mm.h>去掉之后,上面的問題就沒了。
總結
- 上一篇: 滴滴数据通道服务演进之路
- 下一篇: 世界人工智能大会大咖云集,共商赋能传统企