LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Module Programming...file not included (https://www.linuxquestions.org/questions/programming-9/module-programming-file-not-included-373652/)

b_mallerd 10-16-2005 01:51 PM

Module Programming...file not included
 
Hey, I'm just starting module programming and I can insert a simple module but when I try to include the file linux/kernel.h the things that are defined in that file dont get replaced in my program

Code:


#include<linux/module.h>
#include<linux/kernel.h>

int init_module(void)
{
      printk(KERN_ALERT "Hello World!");

      return 0;
}

void cleanup_module(void)
{
    printk("goodbye world.");
}

When i compile that file errors get printed saying that KERN_ALERT was never declared bfore.

I checked the include files and KERN_ALERT stands for "<1>" so i replace it in my source code and the code works fine so I'm sort of confused. I tried to make a test header file and stuck it in /usr/include and that came out fine.

Neone haf ne ideas? :s

Quigi 10-17-2005 10:50 AM

That variable indeed gets defined in http://glide.stanford.edu/lxr/source...nux-2.6.10#L32
But my local /usr/include/linux/kernel.h doesn't have it (Fedora Core 2). Apparently the whole section controlled by __KERNEL__ is missing from my header file. Maybe I'd need to install some kernel development RPM package.

As you say you found the macro in yours, chances are your header file is complete. Try defining the __KERNEL__ macro before any include, e.g.,
#define __KERNEL__ 1
I think you need that anyway to compile a kernel module.

b_mallerd 10-17-2005 12:56 PM

Thx for the reply...

yea I already defined the __KERNEL__ option at compile time. Still no go.


All times are GMT -5. The time now is 06:46 PM.