#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。我哪里错了?