LinuxSir.cn,穿越时空的Linuxsir!

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

error: expected declaration specifiers or ‘...’ before ‘foo’

[复制链接]
发表于 2008-4-16 17:33:27 | 显示全部楼层 |阅读模式
Hey guys. I am trying to implement a system call in linux kernel. I usually use ubutntu, but this I am doing on Fedora. I am using kernel 2.6. Here is what I did:

1. Added a line to arch/i386/kernel/syscall_table.S:

.long sys_foo

2. Added a line to linux/include/asm-i386/unistd.h:

#define __NR_foo 324

also incremented the call count by 1.

3. Added this code to sys.c

[code]
asmlinkage long sys_foo(void)
{
printk("Hello Kernel World");
return THREAD_SIZE;
}
[\code]

4. Wrote this user level client program to test my call:

Code:

#include <unistd.h>
#include <linux/unistd.h>


#define __NR_foo 324
__syscall0(long, foo)

int main()
{

foo();
return 0;
}

However, when I compile the user level program, I get the following error:

success.c:6: error: expected declaration specifiers or ‘...’ before ‘foo’
success.c: In function ‘__syscall0’:
success.c:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
success.c:6: error: parameter name omitted
success.c:13: error: expected ‘{’ at end of input

Anybody has any idea?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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