问题
I am making SYSTEM CALL for linux 2.6.39 kernel.
I have completed all the edits in the files. Now When i am trying to compile the kernel it is showing this error :
error: stdio.h: No such file or directory
If i remove stdio.h, Will the system call work ???
My code is
#include<stdio.h>
#include <linux/linkage.h>
asmlinkage long sys_atvfcfs(int at[], int bt[], int n)
{
int i=0;
int j,t,wt[n],sum,q;
float avgwt;
for(j=i+1;j<n;j++)
{
if(at[i]>at[j])
{
t=at[i];
at[i]=at[j];
at[j]=t;
q=bt[i];
bt[i]=bt[j];
bt[j]=q;
}
}
wt[0]=0;
sum=0;
for(i=0;i<n-1;i++)
{
wt[i+1]=wt[i]+bt[i];
sum=sum+(wt[i+1]-at[i]);
}
avgwt=sum/n;
return avgwt;
}
回答1:
I do'nt see any io functions used in your code, so you don't need to include stdio.h
回答2:
I have no idea what your system call is supposed to do, but it doesn't call any functions declared in stdio.h
. (It doesn't call any functions at all, in fact.) So it should be safe to remove that line.
stdio.h
is a C library header. It's available in ordinary C programs, but a kernel is different. A kernel is self-contained; it can't depend on userspace libraries, because userspace libraries depend on the kernel to do their work. Instead, the kernel has its own internal library of useful functions that you'll want to learn about if you're doing kernel development.
回答3:
You don't need stdio.h in kernel programming. If you need to print something, use printk
instead of printf
.
来源:https://stackoverflow.com/questions/10345778/compiling-kernel-error-stdio-h-no-such-file-or-directory