2002-10-01 18:03:04

by immortal1015

[permalink] [raw]
Subject: compiling errors

I tried to compile the very simple kernel module code as following.
I compile this code using gcc -c hello.c, but gcc tell me:
/usr/include/linux /module.h:60 parse error before 'atomic_t'

What is the error? My gcc version is 2.96.


//////////////////////////////////////////////////////////////////////////////
#ifndef __KERNEL__
# define __KERNEL__
#endif
#ifndef MODULE
# define MODULE
#endif
#include <linux/version.h>
#include <linux/config.h>
#include <linux/module.h>

#include <linux/kernel.h> /* printk */

int init_module(void)
{
printk("<1>Hello the world\n");
return 0;
}

void cleanup_module(void)
{
printk("<1>Goodbye the world\n");
}
/////////////////////////////////////////////////////////////////


Best regards
yours Brucie





2002-10-01 18:13:47

by Arjan van de Ven

[permalink] [raw]
Subject: Re: compiling errors

On Tue, 2002-10-01 at 20:07, immortal1015 wrote:
> I tried to compile the very simple kernel module code as following.
> I compile this code using gcc -c hello.c, but gcc tell me:
> /usr/include/linux /module.h:60 parse error before 'atomic_t'

you are using glibc headers to compile kernel code....

add -I/lib/modules/`uname -r`/build/include
to the gcc flags



Attachments:
signature.asc (189.00 B)
This is a digitally signed message part