return (0) is a must in init_module Daniel Marian wrote: > Hello Mohan, > I think you have to add the following 2 lines to your code > > #define __KERNEL__ > #define MODULE > > remove <linux/sched.h> > > It compiled in my machine(Linux 7.0) > > regards > daniel. > > "C.Mohanasundaram" wrote: > > > Hi all, > > > > i was trying to write a kernel module and i got some compilation error when i > > included sched.h. so i wrote a simple module to test it. i got the same > > compilation error.I have given the code, makefile and also the dump of the > > error below. What is the mistake i m doing > > I m using RedHat 7.1 and my kernel version is 2.4.2-2 on an i686 > > > > /*code*/ > > > > #include <linux/kernel.h> > > #include <linux/module.h> > > #include <linux/sched.h> > > > > int init_module() > > { > > printk("Hello"); > > } > > > > void cleanup_module() > > { > > printk("Bye"); > > } > > > > #------------------------------------ > > #makefile > > #------------------------------------ > > > > KERNELDIR=/usr/src/linux-2.4.2 > > > > testmod.o : > > gcc -DKERNEL -DMODULE -DLINUX -O2 -Wall -I$(KERNELDIR)/include -c testmod.c > > > > clean : > > rm -f *.o *~ core > > > > ###################### > > #compilation error > > ###################### > > In file included from /usr/src/linux-2.4.2/include/linux/sched.h:15, > > from testmod.c:3: > > /usr/src/linux-2.4.2/include/linux/timex.h:171: field `time' has incomplete > > type > > In file included from /usr/src/linux-2.4.2/include/linux/sched.h:80, > > from testmod.c:3: > > /usr/src/linux-2.4.2/include/linux/timer.h:21: field `vec' has incomplete type > > /usr/src/linux-2.4.2/include/linux/timer.h:26: field `vec' has incomplete type > > /usr/src/linux-2.4.2/include/linux/timer.h:52: field `list' has incomplete > > type > > /usr/src/linux-2.4.2/include/linux/timer.h: In function `timer_pending': > > /usr/src/linux-2.4.2/include/linux/timer.h:111: warning: control reaches end > > of non-void function > > testmod.c: In function `init_module': > > testmod.c:7: warning: implicit declaration of function `printk' > > testmod.c:8: warning: control reaches end of non-void function > > make: *** [testmod.o] Error 1 > > > > thanks and regards, > > mohan > > - > > Kernelnewbies: Help each other learn about the Linux kernel. > > Archive: http://mail.nl.linux.org/kernelnewbies/ > > IRC Channel: irc.openprojects.net / #kernelnewbies > > Web Page: http://www.kernelnewbies.org/ > > ------------------------------------------------------------------------------------------------------------------------ > Name: Wipro_Disclaimer.txt > Wipro_Disclaimer.txt Type: Plain Text (text/plain) > Encoding: 7bit
----------------------------------------------------------------------------------------------------------------------- Information transmitted by this E-MAIL is proprietary to Wipro and/or its Customers and is intended for use only by the individual or entity to which it is addressed, and may contain information that is privileged, confidential or exempt from disclosure under applicable law. If you are not the intended recipient or it appears that this mail has been forwarded to you without proper authority, you are notified that any use or dissemination of this information in any manner is strictly prohibited. In such cases, please notify us immediately at mailto:mailadmin@wipro.com and delete this mail from your records. ------------------------------------------------------------------------------------------------------------------------