0
#include <linux/sched.h>
#include <stdio.h>
#include <stdlib.h>
int
main(int argc, char *argv[])
{
struct task_struct *task;
task = current;
printf("Proc PID is %ld\n",(long)task->pid);
exit(EXIT_SUCCESS);
}
我收到以下错误,当我尝试编译:编译错误,同时试图使用“当前”宏
*current.c: In function ‘main’:
current.c:9:9: error: ‘current’ undeclared (first use in this function)
current.c:9:9: note: each undeclared identifier is reported only once for each function it appears in
current.c:10:40: error: dereferencing pointer to incomplete type*
我使用的是Linux内核3.2.0.4-amd64的。 我哪里错了?
Thx。那么试验内核的API并构建一个可用的示例代码的正确方法是什么? – FabriX 2013-04-27 11:00:38
我想你可以创建一个内核模块来试验内核的API。 – 2013-04-29 02:21:54
这个快速手册将回答你的问题http://tldp.org/LDP/lkmpg/2.6/html/ – 2013-05-01 12:12:37