Re: A Newbie question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



try using -D__KERNEL__  in ur gcc option ...
but sometimes even the version can be problem.....but not necessarily..
no harm in trying
-include /usr/src/linux-2.4.2/include/linux/modversions.h
nk

"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/

-
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/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux