LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-16-2005, 01:51 PM   #1
b_mallerd
LQ Newbie
 
Registered: Jun 2005
Posts: 5

Rep: Reputation: 0
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
 
Old 10-17-2005, 10:50 AM   #2
Quigi
Member
 
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377

Rep: Reputation: 31
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.

Last edited by Quigi; 10-17-2005 at 10:51 AM.
 
Old 10-17-2005, 12:56 PM   #3
b_mallerd
LQ Newbie
 
Registered: Jun 2005
Posts: 5

Original Poster
Rep: Reputation: 0
Thx for the reply...

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
D-Link DUB-H4 USB2.0 is not detected When EHCI-hcd.o module is included in 2.4.26 skannan Linux - Hardware 2 05-29-2005 10:59 PM
Programming a module.. need help tantrix Programming 3 04-14-2005 06:15 PM
File Permissions, CHMOD problems, image included. DeathGoth Programming 16 10-05-2004 09:51 PM
How to compile a C program in Glade which is included the <pcap.h> header file. swaviswa Programming 0 03-21-2004 07:47 AM
Module programming linuxanswer Programming 2 12-12-2003 02:16 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration