2

I'm compiling a kernel module and I'm including <asm/unistd.h>, but I'm not sure if the compiler is using the unistd.h from /usr/includes/ (wrong) or the one from /usr/src/kernel-3.x.x/arch/x86/includes/ (right).

My question is: How can I check which one of those two is the compiler using?

And also, is there a way to force the file from the kernel headers instead of the one from /usr/include?

4

2 回答 2

1

要回答您问题的第二部分:

而且,有没有办法从内核头文件中强制文件而不是 from /usr/include

您可以将-nostdinc选项传递给gcc

“不要在标准系统目录中搜索头文件。仅搜索您使用 -I 选项指定的目录(以及当前文件的目录,如果适用)。”

GCC:控制预处理器的选项

于 2013-11-20T02:24:16.287 回答
1
cpp code.c | grep unistd.h

或者

gcc -E code.c | grep unistd.h
于 2013-10-18T14:44:27.407 回答