我正在尝试使用 llvm-gcc(llvm 版本 1.7)在 linux 内核源代码(版本 2.6.18.8)中编译驱动程序(linux/drivers/net/zorro8390.c)以用于研究目的,但我得到了jiffies.h 中的很多错误:
bash-3.2$ llvm-gcc -D__GNUCC -E -I../../include zorro8390.c -o test.o
In file included from ../../include/linux/lockdep.h:12,
from ../../include/linux/spinlock_types.h:12,
from ../../include/linux/spinlock.h:78,
from ../../include/linux/module.h:10,
from zorro8390.c:22:
../../include/linux/list.h:887:2: warning: #warning "don't include kernel headers in userspace"
In file included from zorro8390.c:30:
../../include/linux/jiffies.h:210:31: error: division by zero in #if
../../include/linux/jiffies.h:210:31: error: division by zero in #if
...(a bunch of same errors)
../../include/linux/jiffies.h:432:28: error: division by zero in #if
我在谷歌上搜索了很多关于这个错误的讨论,但其中很多都是关于使用 make 命令构建内核的。直接使用 llvm-gcc 时我仍然不知道如何修复它。有什么建议吗?非常感谢您的帮助!
丹尼尔