I keep getting "implicit declaration of <some function>" error quite often. So I'm assuming I am not adding the correct header files when I am writing the module. eg. I wanted to create a kernel thread using ktheard_create/kthread_run, but couldn't find which header to include. While I was looking for solutions I stumbled upon ctags. It mostly gets the job done, but not always. I couldn't find the proper header to use for open(inode,file); even though ctags pointed me to <linux/fs.h>, I still get the implicit declaration error. Is there any way of finding exactly which headers to include when one is trying to use a function? A detailed explanation would be really great.
This is ONLY a hint for finding the header files in the /usr/src/linux directory. I do generally like this. find include -type f | xargs grep "kthread_run" Replace "kthread_run" with new strings for searching. This is ONLY a HINT but you asked for clear explanation. Regards, Srinivas. On Fri, Jul 19, 2013 at 3:38 PM, Ritesh Ranjan <r.ranjan789@gmail.com>wrote:
I keep getting "implicit declaration of <some function>" error quite often. So I'm assuming I am not adding the correct header files when I am writing the module.
eg. I wanted to create a kernel thread using ktheard_create/kthread_run, but couldn't find which header to include. While I was looking for solutions I stumbled upon ctags. It mostly gets the job done, but not always. I couldn't find the proper header to use for open(inode,file); even though ctags pointed me to <linux/fs.h>, I still get the implicit declaration error.
Is there any way of finding exactly which headers to include when one is trying to use a function? A detailed explanation would be really great.
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
On Fri, 19 Jul 2013 16:49:13 +0530, Srinivas Ganji said:
This is ONLY a hint for finding the header files in the /usr/src/linux directory. I do generally like this.
find include -type f | xargs grep "kthread_run"
Remember that there's arch-dependent headers as well. You may want this: find include/ arch/FOO/include/ -type f | .... for an appropriate value of FOO (usually x86 or arm, unless you're on a powerpc or a sparc or one of the 23 other archs.. ;) Won't ake a difference for the specific case of kthread_run, but you're not going to find something like vdso.h under include/
On Fri, Jul 19, 2013 at 3:38 PM, Ritesh Ranjan <r.ranjan789@gmail.com>wrote:
I keep getting "implicit declaration of <some function>" error quite often. So I'm assuming I am not adding the correct header files when I am writing the module.
eg. I wanted to create a kernel thread using ktheard_create/kthread_run, but couldn't find which header to include. While I was looking for solutions I stumbled upon ctags. It mostly gets the job done, but not always. I couldn't find the proper header to use for open(inode,file); even though ctags pointed me to <linux/fs.h>, I still get the implicit declaration error.
Is there any way of finding exactly which headers to include when one is trying to use a function? A detailed explanation would be really great.
For the specific header: http://lxr.free-electrons.com/ident?i=kthread_run Generally, Ctags is pretty good at finding things. In case you're not getting the right def of a fxn, check the tag list in case there are multiple functions defined with the same name. I forgot the vi command (I think it was "ts" or "tl"), but it'll list down the various defs it found for the fxn. You can then navigate to the specific file of your interest. HTH, -mandeep
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
participants (4)
-
Mandeep Sandhu -
Ritesh Ranjan -
Srinivas Ganji -
Valdis.Kletnieks@vt.edu