我是初学者,我正在尝试linux中的一些内核编程基础知识.今天早上我在VIM中打开了module.h文件,关闭后也没有保存任何更改.之后,我无法编译任何代码.我收到以下错误消息
[root@localhost helloworld]# cc helloworld.c
helloworld.c:1:25: error: linux/module.h: No such file or directory
[root@localhost helloworld]#
Run Code Online (Sandbox Code Playgroud)
这是一个成功运行到最后一天的示例代码.
#include<linux/module.h>
#include<linux/kernel.h>
int init_module(void)
{
printk("HELLO WORLD");
return 0;
}
void cleanup_module(void)
{
printk("GOODBYE");
}
Run Code Online (Sandbox Code Playgroud)
我搜索了module.h文件,如下所示,它确实存在
[root@localhost usr]# find . -name module.h
./src/kernels/2.6.18-194.el5-i686/include/asm-x86_64/module.h
./src/kernels/2.6.18-194.el5-i686/include/asm-i386/module.h
./src/kernels/2.6.18-194.el5-i686/include/linux/module.h
./include/sepol/policydb/module.h
./include/sepol/module.h
./include/kde/kunittest/module.h
[root@localhost usr]#
Run Code Online (Sandbox Code Playgroud)
请帮帮我.我在虚拟盒子里使用CentOS.
嗨,我是初学者,我正在尝试找出一些指向函数示例的指针.我甚至无法编译我的代码,它显示以下消息.我无法确定为什么我收到编译错误.
/tmp/cc0qghbo.o: In function `main':
pointer_to_function_inside_structure.c:(.text+0x88): undefined reference to `func_ptr'
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
这是我的代码,请告诉我我做错了什么
#include<stdio.h>
#include<stdlib.h>
struct student_data
{
char *name;
int roll_num;
int marks;
void (* func_ptr)(struct student_data *ptr);
};
void print_data(struct student_data *ptr);
void print_data(struct student_data *ptr)
{
printf("\nNAME OF THE STUDENT %s", ptr -> name);
printf("\nROLL NUMBER OF STUDENT %d", ptr -> roll_num);
printf("\nMARKS OF STUDENT %d\n", ptr -> marks);
}
int main()
{
struct student_data *ptr;
ptr -> name = "ajish";
ptr -> …Run Code Online (Sandbox Code Playgroud) 我是内核编程的新手.当我尝试在我的角色设备文件代码中使用scanf时,我收到此错误消息:错误:隐式声明函数'scanf'
我怎么解决这个问题 ?请帮帮我.
我在虚拟盒子里使用linux CentOS.