LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 762|回复: 1

是不是内核版本的问题

[复制链接]
发表于 2006-2-9 20:59:57 | 显示全部楼层 |阅读模式
//我的程序如下,是本站上的一个程序,却出了这样一些错误,请大侠帮我看看是不是由于系统版//本的问题,我的机器是i686的,但是好像这个程序应该是前面版本的,不知谁知道这是什么问题?
#include <linux/kernel.h> /* 内核工作 */
#include <linux/module.h> /* 明确指定是模块 */

/* 处理CONFIG_MODVERSIONS */
#if CONFIG_MODVERSIONS==1
#define MODVERSIONS
#include <linux/modversions.h>
#endif

/* 使用proc 文件系统所必要的 */
#include <linux/proc_fs.h>

int procfile_read(char *buffer,
char **buffer_location,
off_t offset,
int buffer_length,
int zero)
{
int len;/* The number of bytes actually used */

/* 这是静态的,因此当我们离开这个函数时它还会待在内存中 */
static char my_buffer[80];

static int count = 1;

if (offset > 0)
return 0;

/* 填充缓冲区并得到长度 */
len = sprintf(my_buffer,
"For the %d%s time, go away!\n", count,
(count % 100 > 10 && count % 100 < 14) ? "th" :
(count % 10 == 1) ? "st" :
(count % 10 == 2) ? "nd" :
(count % 10 == 3) ? "rd" : "th" );
count++;

/* 告诉调用函数缓冲区在哪儿*/
*buffer_location = my_buffer;

/* 返回长度 */
return len;
}


struct proc_dir_entry Our_Proc_File =
{
0, /* 节点数 - 忽略,它将被 proc_register[_dynamic] 填充*/
4, /* 文件名长度 */
"test", /* 文件名*/
S_IFREG | S_IRUGO, /* 文件模式 - 这是一个可以被拥有者,用户组和其他所有的用户读取的普通文件 */
1, /* 连接数 (文件被引用的目录数) */
0, 0, /* 文件的UID和GID - 我们将它赋予 root */
80, /* 用ls报告的文件大小。 */
NULL, /* 使用节点的函数(连接,删除,等等)--我们不支持 */
procfile_read, /* 对这个文件的读函数,当某人试图葱它读入什么时被调用。 */
NULL /* 我们能够在这儿有一个填充文件节点的函数,允许我们修改权限和拥有权,等等。 */
};



/* 初始化模块--登记 proc 文件 */
int init_module()
{
return proc_register(&proc_root, &Our_Proc_File);
}


/* 清除 - 从 /proc中注销我们的文件 */
void cleanup_module()
{
proc_unregister(&proc_root, Our_Proc_File.low_ino);
}




/*编译:gcc -c -Wall -D__KERNEL__ -DMODULE test.c
却有如下错误,
In file included from /usr/include/linux/sched.h:14,
                 from /usr/include/linux/module.h:9,
                 from test.c:9:
/usr/include/linux/cpumask.h:85: error: syntax error before 'DECLARE_BITMAP'
/usr/include/linux/cpumask.h:86: error: syntax error before '_unused_cpumask_arg_'
/usr/include/linux/cpumask.h:89: error: syntax error before '*' token
/usr/include/linux/cpumask.h: In function '__cpu_set':
/usr/include/linux/cpumask.h:91: error: 'cpu' undeclared (first use in this function)
/usr/include/linux/cpumask.h:91: error: (Each undeclared identifier is reported only once
/usr/include/linux/cpumask.h:91: error: for each function it appears in.)
/usr/include/linux/cpumask.h:91: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:95: error: syntax error before '*' token
/usr/include/linux/cpumask.h: In function '__cpu_clear':
/usr/include/linux/cpumask.h:97: error: 'cpu' undeclared (first use in this function)
/usr/include/linux/cpumask.h:97: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:101: error: syntax error before '*' token
/usr/include/linux/cpumask.h: In function '__cpus_setall':
/usr/include/linux/cpumask.h:103: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:103: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:107: error: syntax error before '*' token
/usr/include/linux/cpumask.h: In function '__cpus_clear':
/usr/include/linux/cpumask.h:109: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:109: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:116: error: syntax error before 'cpumask_t'
/usr/include/linux/cpumask.h: In function '__cpu_test_and_set':
/usr/include/linux/cpumask.h:118: error: 'cpu' undeclared (first use in this function)
/usr/include/linux/cpumask.h:118: error: 'addr' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:122: error: syntax error before '*' token
/usr/include/linux/cpumask.h: In function '__cpus_and':
/usr/include/linux/cpumask.h:125: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:125: error: 'src1p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:125: error: 'src2p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:125: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:129: error: syntax error before '*' token
/usr/include/linux/cpumask.h: In function '__cpus_or':
/usr/include/linux/cpumask.h:132: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:132: error: 'src1p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:132: error: 'src2p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:132: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:136: error: syntax error before '*' token
/usr/include/linux/cpumask.h: In function '__cpus_xor':
/usr/include/linux/cpumask.h:139: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:139: error: 'src1p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:139: error: 'src2p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:139: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:144: error: syntax error before '*' token
/usr/include/linux/cpumask.h: In function '__cpus_andnot':
/usr/include/linux/cpumask.h:147: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:147: error: 'src1p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:147: error: 'src2p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:147: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:151: error: syntax error before '*' token
/usr/include/linux/cpumask.h: In function '__cpus_complement':
/usr/include/linux/cpumask.h:154: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:154: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:154: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:158: error: syntax error before '*' token
/usr/include/linux/cpumask.h: In function '__cpus_equal':
/usr/include/linux/cpumask.h:161: error: 'src1p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:161: error: 'src2p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:161: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:165: error: syntax error before '*' token
/usr/include/linux/cpumask.h: In function '__cpus_intersects':
/usr/include/linux/cpumask.h:168: error: 'src1p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:168: error: 'src2p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:168: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:172: error: syntax error before '*' token
/usr/include/linux/cpumask.h: In function '__cpus_subset':
/usr/include/linux/cpumask.h:175: error: 'src1p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:175: error: 'src2p' undeclared (first use in this function)
/usr/include/linux/cpumask.h:175: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:179: error: syntax error before '*' token
/usr/include/linux/cpumask.h: In function '__cpus_empty':
/usr/include/linux/cpumask.h:181: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:181: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:185: error: syntax error before '*' token
/usr/include/linux/cpumask.h: In function '__cpus_full':
/usr/include/linux/cpumask.h:187: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:187: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:191: error: syntax error before '*' token
/usr/include/linux/cpumask.h: In function '__cpus_weight':
/usr/include/linux/cpumask.h:193: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:193: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:198: error: syntax error before '*' token
/usr/include/linux/cpumask.h: In function '__cpus_shift_right':
/usr/include/linux/cpumask.h:201: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:201: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:201: error: 'n' undeclared (first use in this function)
/usr/include/linux/cpumask.h:201: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:206: error: syntax error before '*' token
/usr/include/linux/cpumask.h: In function '__cpus_shift_left':
/usr/include/linux/cpumask.h:209: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:209: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:209: error: 'n' undeclared (first use in this function)
/usr/include/linux/cpumask.h:209: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:213: error: syntax error before '*' token
/usr/include/linux/cpumask.h: In function '__first_cpu':
/usr/include/linux/cpumask.h:215: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h:215: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:219: error: syntax error before '*' token
/usr/include/linux/cpumask.h: In function '__next_cpu':
/usr/include/linux/cpumask.h:221: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h:221: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:221: error: 'n' undeclared (first use in this function)
In file included from /usr/include/linux/sched.h:14,
                 from /usr/include/linux/module.h:9,
                 from test.c:9:
/usr/include/linux/cpumask.h:238:5: error: missing binary operator before token "("
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:270: error: syntax error before '*' token
/usr/include/linux/cpumask.h: In function '__cpumask_scnprintf':
/usr/include/linux/cpumask.h:272: error: 'buf' undeclared (first use in this function)
/usr/include/linux/cpumask.h:272: error: 'len' undeclared (first use in this function)
/usr/include/linux/cpumask.h:272: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:272: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:278: error: syntax error before 'cpumask_t'
/usr/include/linux/cpumask.h: In function '__cpumask_parse':
/usr/include/linux/cpumask.h:280: error: 'buf' undeclared (first use in this function)
/usr/include/linux/cpumask.h:280: error: 'len' undeclared (first use in this function)
/usr/include/linux/cpumask.h:280: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:280: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:286: error: syntax error before '*' token
/usr/include/linux/cpumask.h: In function '__cpulist_scnprintf':
/usr/include/linux/cpumask.h:288: error: 'buf' undeclared (first use in this function)
/usr/include/linux/cpumask.h:288: error: 'len' undeclared (first use in this function)
/usr/include/linux/cpumask.h:288: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:288: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:292: error: syntax error before 'cpumask_t'
/usr/include/linux/cpumask.h: In function '__cpulist_parse':
/usr/include/linux/cpumask.h:294: error: 'buf' undeclared (first use in this function)
/usr/include/linux/cpumask.h:294: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/cpumask.h:294: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/cpumask.h:297:5: error: missing binary operator before token "("
/usr/include/linux/cpumask.h: At top level:
/usr/include/linux/cpumask.h:362: error: syntax error before 'cpu_possible_map'
/usr/include/linux/cpumask.h:363: error: syntax error before 'cpu_online_map'
/usr/include/linux/cpumask.h:364: error: syntax error before 'cpu_present_map'
/usr/include/linux/cpumask.h:366:5: error: missing binary operator before token "("
In file included from /usr/include/linux/sched.h:16,
                 from /usr/include/linux/module.h:9,
                 from test.c:9:
/usr/include/linux/nodemask.h:85: error: syntax error before 'DECLARE_BITMAP'
/usr/include/linux/nodemask.h:86: error: syntax error before '_unused_nodemask_arg_'
/usr/include/linux/nodemask.h:89: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__node_set':
/usr/include/linux/nodemask.h:91: error: 'node' undeclared (first use in this function)
/usr/include/linux/nodemask.h:91: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:95: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__node_clear':
/usr/include/linux/nodemask.h:97: error: 'node' undeclared (first use in this function)
/usr/include/linux/nodemask.h:97: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:101: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__nodes_setall':
/usr/include/linux/nodemask.h:103: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:103: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:107: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__nodes_clear':
/usr/include/linux/nodemask.h:109: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:109: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:117: error: syntax error before 'nodemask_t'
/usr/include/linux/nodemask.h: In function '__node_test_and_set':
/usr/include/linux/nodemask.h:119: error: 'node' undeclared (first use in this function)
/usr/include/linux/nodemask.h:119: error: 'addr' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:124: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__nodes_and':
/usr/include/linux/nodemask.h:127: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:127: error: 'src1p' undeclared (first use in this function)
/usr/include/linux/nodemask.h:127: error: 'src2p' undeclared (first use in this function)
/usr/include/linux/nodemask.h:127: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:132: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__nodes_or':
/usr/include/linux/nodemask.h:135: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:135: error: 'src1p' undeclared (first use in this function)
/usr/include/linux/nodemask.h:135: error: 'src2p' undeclared (first use in this function)
/usr/include/linux/nodemask.h:135: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:140: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__nodes_xor':
/usr/include/linux/nodemask.h:143: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:143: error: 'src1p' undeclared (first use in this function)
/usr/include/linux/nodemask.h:143: error: 'src2p' undeclared (first use in this function)
/usr/include/linux/nodemask.h:143: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:148: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__nodes_andnot':
/usr/include/linux/nodemask.h:151: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:151: error: 'src1p' undeclared (first use in this function)
/usr/include/linux/nodemask.h:151: error: 'src2p' undeclared (first use in this function)
/usr/include/linux/nodemask.h:151: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:156: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__nodes_complement':
/usr/include/linux/nodemask.h:159: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:159: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:159: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:164: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__nodes_equal':
/usr/include/linux/nodemask.h:167: error: 'src1p' undeclared (first use in this function)
/usr/include/linux/nodemask.h:167: error: 'src2p' undeclared (first use in this function)
/usr/include/linux/nodemask.h:167: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:172: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__nodes_intersects':
/usr/include/linux/nodemask.h:175: error: 'src1p' undeclared (first use in this function)
/usr/include/linux/nodemask.h:175: error: 'src2p' undeclared (first use in this function)
/usr/include/linux/nodemask.h:175: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:180: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__nodes_subset':
/usr/include/linux/nodemask.h:183: error: 'src1p' undeclared (first use in this function)
/usr/include/linux/nodemask.h:183: error: 'src2p' undeclared (first use in this function)
/usr/include/linux/nodemask.h:183: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:187: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__nodes_empty':
/usr/include/linux/nodemask.h:189: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:189: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:193: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__nodes_full':
/usr/include/linux/nodemask.h:195: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:195: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:199: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__nodes_weight':
/usr/include/linux/nodemask.h:201: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:201: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:206: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__nodes_shift_right':
/usr/include/linux/nodemask.h:209: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:209: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:209: error: 'n' undeclared (first use in this function)
/usr/include/linux/nodemask.h:209: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:214: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__nodes_shift_left':
/usr/include/linux/nodemask.h:217: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:217: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:217: error: 'n' undeclared (first use in this function)
/usr/include/linux/nodemask.h:217: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:224: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__first_node':
/usr/include/linux/nodemask.h:226: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:230: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__next_node':
/usr/include/linux/nodemask.h:232: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:232: error: 'n' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:248: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__first_unset_node':
/usr/include/linux/nodemask.h:250: error: 'maskp' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:283: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__nodemask_scnprintf':
/usr/include/linux/nodemask.h:285: error: 'buf' undeclared (first use in this function)
/usr/include/linux/nodemask.h:285: error: 'len' undeclared (first use in this function)
/usr/include/linux/nodemask.h:285: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:285: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:291: error: syntax error before 'nodemask_t'
/usr/include/linux/nodemask.h: In function '__nodemask_parse':
/usr/include/linux/nodemask.h:293: error: 'buf' undeclared (first use in this function)
/usr/include/linux/nodemask.h:293: error: 'len' undeclared (first use in this function)
/usr/include/linux/nodemask.h:293: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:293: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:299: error: syntax error before '*' token
/usr/include/linux/nodemask.h: In function '__nodelist_scnprintf':
/usr/include/linux/nodemask.h:301: error: 'buf' undeclared (first use in this function)
/usr/include/linux/nodemask.h:301: error: 'len' undeclared (first use in this function)
/usr/include/linux/nodemask.h:301: error: 'srcp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:301: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:305: error: syntax error before 'nodemask_t'
/usr/include/linux/nodemask.h: In function '__nodelist_parse':
/usr/include/linux/nodemask.h:307: error: 'buf' undeclared (first use in this function)
/usr/include/linux/nodemask.h:307: error: 'dstp' undeclared (first use in this function)
/usr/include/linux/nodemask.h:307: error: 'nbits' undeclared (first use in this function)
/usr/include/linux/nodemask.h: At top level:
/usr/include/linux/nodemask.h:326: error: syntax error before 'node_online_map'
/usr/include/linux/nodemask.h:327: error: syntax error before 'node_possible_map'
In file included from /usr/include/linux/list.h:7,
                 from /usr/include/linux/wait.h:23,
                 from /usr/include/asm/semaphore.h:41,
                 from /usr/include/linux/sched.h:19,
                 from /usr/include/linux/module.h:9,
                 from test.c:9:
/usr/include/linux/prefetch.h: In function 'prefetch_range':
/usr/include/linux/prefetch.h:64: error: 'CONFIG_X86_L1_CACHE_SHIFT' undeclared (first use in this function)
In file included from /usr/include/asm/siginfo.h:4,
                 from /usr/include/linux/signal.h:7,
                 from /usr/include/linux/sched.h:27,
                 from /usr/include/linux/module.h:9,
                 from test.c:9:
/usr/include/asm-generic/siginfo.h: At top level:
/usr/include/asm-generic/siginfo.h:58: error: size of array '_pad' is too large
In file included from /usr/include/linux/module.h:9,
                 from test.c:9:
/usr/include/linux/sched.h:162: error: syntax error before 'nohz_cpu_mask'
In file included from /usr/include/linux/module.h:9,
                 from test.c:9:
/usr/include/linux/sched.h:252: error: syntax error before 'cpumask_t'
/usr/include/linux/sched.h:273: error: syntax error before '}' token
/usr/include/linux/sched.h:600: error: syntax error before 'cpumask_t'
/usr/include/linux/sched.h:624: error: syntax error before ':' token
/usr/include/linux/sched.h:665: error: syntax error before ':' token
/usr/include/linux/sched.h:750: error: syntax error before '}' token
/usr/include/linux/sched.h: In function 'process_group':
/usr/include/linux/sched.h:754: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'pid_alive':
/usr/include/linux/sched.h:767: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: At top level:
/usr/include/linux/sched.h:830: error: syntax error before 'cpumask_t'
/usr/include/linux/sched.h: In function 'set_cpus_allowed':
/usr/include/linux/sched.h:832: error: 'new_mask' undeclared (first use in this function)
/usr/include/linux/sched.h: In function 'dequeue_signal_lock':
/usr/include/linux/sched.h:935: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h:937: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'on_sig_stack':
/usr/include/linux/sched.h:977: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h:977: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'sas_ss_flags':
/usr/include/linux/sched.h:982: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'capable':
/usr/include/linux/sched.h:993: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h:994: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'mmdrop':
/usr/include/linux/sched.h:1017: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: At top level:
/usr/include/linux/sched.h:1033: error: 'exit_signal' redeclared as different kind of symbol
/usr/include/linux/sched.h:620: error: previous declaration of 'exit_signal' was here
/usr/include/linux/sched.h: In function 'thread_group_empty':
/usr/include/linux/sched.h:1096: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'task_lock':
/usr/include/linux/sched.h:1114: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'task_unlock':
/usr/include/linux/sched.h:1119: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'set_tsk_thread_flag':
/usr/include/linux/sched.h:1127: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'clear_tsk_thread_flag':
/usr/include/linux/sched.h:1132: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'test_and_set_tsk_thread_flag':
/usr/include/linux/sched.h:1137: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'test_and_clear_tsk_thread_flag':
/usr/include/linux/sched.h:1142: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: In function 'test_tsk_thread_flag':
/usr/include/linux/sched.h:1147: error: dereferencing pointer to incomplete type
/usr/include/linux/sched.h: At top level:
/usr/include/linux/sched.h:1250: error: syntax error before 'cpumask_t'
/usr/include/linux/sched.h:1251: error: syntax error before 'cpumask_t'
In file included from /usr/include/linux/module.h:22,
                 from test.c:9:
/usr/include/asm/module.h:60:2: error: #error unknown processor family
test.c:100: warning: initialization from incompatible pointer type
test.c: In function 'init_module':
test.c:116: warning: implicit declaration of function 'proc_register_dynamic'
test.c: In function 'cleanup_module':
test.c:126: warning: implicit declaration of function 'proc_unregister'
test.c:127:2: warning: no newline at end of file*/
发表于 2006-2-10 14:31:08 | 显示全部楼层
Post by WCW
gcc -c -Wall -D__KERNEL__ -DMODULE test.c
...
/usr/include/linux/cpumask.h:85: error: syntax error before 'DECLARE_BITMAP'


编译模块应该使用自己内核中的头文件,而不是 /usr/include/linux 中的文件。
下面是从内核编译某模块时选出来的:
  1. gcc -Wall -O2 -fomit-frame-pointer -D__KERNEL__ -DMODULE -I/usr/src/linux/include -nostdinc -iwithprefix include test.c
复制代码


而且一般说来 init_module 和 cleanup_module 的声明方法也过时了,可以看看内核中任意一个模块的写法,现在用 module_init 和 module_exit 宏,描述更具体。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表