【发布时间】:2014-03-01 09:51:15
【问题描述】:
我正在阅读 FreeBSD 设备驱动程序一书。 第一个例子是 hello.c。但是,当我编译它时,它说 hello.c:1:10: fatal error: 'sys/param.h' file not found
你好.c
#include <sys/param.h>
#include <sys/module.h>
#include <sys/kernel.h>
#include <sys/systm.h>
static int
hello_modevent(module_t mod __unused, int event, void *arg __unused)
{
int error = 0;
switch (event)
{
case MOD_LOAD:
uprintf("Hello, world\n");
case MOD_UNLOAD:
uprintf("GoodBye, cruel world");
default:
error = EOPNETSUPP;
}
return (error);
}
static moduledata_t hello_mod = {
"hello",
hello_modevent,
NULL
}
DECLARE_MODULE(hello, hello_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);
生成文件
KMOD= hello
SRCS= hello.c
.include <bsd.kmod.mk>
uname -a FreeBSD FreeBSD-1 10.0-RELEASE FreeBSD 10.0-RELEASE #0 r260789:2014 年 1 月 17 日星期五 01:46:25 UTC root@snap.freebsd.org:/usr/obj/usr/src/sys/GENERIC i386
非常感谢。 添加:
After I type make, the problem is
Warning: Object directory not changed from original /usr/home/user/Workplaces/hello
cc -O2 -pipe -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc -I. -I@ -I@/contrib/altq -fno-common -mno-aes -mno-avx -mno-mmx -mno-sse -msoft-float -ffreestanding -fstack-protector -std=iso9899:1999 -Qunused-arguments -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -Wundef -Wno-pointer-sign -fformat-extensions -Wmissing-include-dirs -fdiagnostics-show-option -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -c hello.c
hello.c:1:10: fatal error: 'sys/param.h' file not found
#include <sys/param.h>
^
1 error generated.
*** Error code 1
【问题讨论】: