Unix Programming - module compile problem

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > March 2006 > module compile problem





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author module compile problem
zz

2006-03-12, 7:47 am

a "hello world" module sample in ldd3:
////////////////////////////////////////////////
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");

static int hello_init(void)
{
printk(KERN_ALERT "Hello, World!\n");
return 0;
}

static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, cruel world!\n");
}
module_init(hello_init);
module_exit(hello_exit);
//////////////////////////////////////////
i compiled it with gcc:
//////////////////////////////////////////
$gcc -c -I/usr/src/linux/include hello.c
//////////////////////////////////////////
but it generated a ton of such error:
////////////////////////////////////////////
/usr/src/linux/include/linux/time.h:13: error: syntax error before 'time_t'
/usr/src/linux/include/linux/time.h:13: warning: no semicolon at end of struct or union
/usr/src/linux/include/linux/time.h:15: error: syntax error before '}' token
/usr/src/linux/include/linux/time.h:19: error: syntax error before 'time_t'
/usr/src/linux/include/linux/time.h:19: warning: no semicolon at end of struct or union
/usr/src/linux/include/linux/time.h:20: warning: data definition has no type or
storage class
/usr/src/linux/include/linux/time.h:136: error: field 'it_interval' has incomplete type
/usr/src/linux/include/linux/time.h:137: error: field 'it_value' has incomplete
type
/usr/src/linux/include/linux/time.h:141: error: field 'it_interval' has incomplete type
/usr/src/linux/include/linux/time.h:142: error: field 'it_value' has incomplete
type
In file included from /usr/src/linux/include/linux/sched.h:11,
//////////////////////////////////////////
who can tell me why?? thanks a lot!!!

Fletcher Glenn

2006-03-13, 5:54 pm

zz wrote:
> a "hello world" module sample in ldd3:
> ////////////////////////////////////////////////
> #include <linux/init.h>
> #include <linux/module.h>
> MODULE_LICENSE("Dual BSD/GPL");
>
> static int hello_init(void)
> {
> printk(KERN_ALERT "Hello, World!\n");
> return 0;
> }
>
> static void hello_exit(void)
> {
> printk(KERN_ALERT "Goodbye, cruel world!\n");
> }
> module_init(hello_init);
> module_exit(hello_exit);
> //////////////////////////////////////////
> i compiled it with gcc:
> //////////////////////////////////////////
> $gcc -c -I/usr/src/linux/include hello.c
> //////////////////////////////////////////
> but it generated a ton of such error:
> ////////////////////////////////////////////
> /usr/src/linux/include/linux/time.h:13: error: syntax error before 'time_t'
> /usr/src/linux/include/linux/time.h:13: warning: no semicolon at end of struct or union
> /usr/src/linux/include/linux/time.h:15: error: syntax error before '}' token
> /usr/src/linux/include/linux/time.h:19: error: syntax error before 'time_t'
> /usr/src/linux/include/linux/time.h:19: warning: no semicolon at end of struct or union
> /usr/src/linux/include/linux/time.h:20: warning: data definition has no type or
> storage class
> /usr/src/linux/include/linux/time.h:136: error: field 'it_interval' has incomplete type
> /usr/src/linux/include/linux/time.h:137: error: field 'it_value' has incomplete
> type
> /usr/src/linux/include/linux/time.h:141: error: field 'it_interval' has incomplete type
> /usr/src/linux/include/linux/time.h:142: error: field 'it_value' has incomplete
> type
> In file included from /usr/src/linux/include/linux/sched.h:11,
> //////////////////////////////////////////
> who can tell me why?? thanks a lot!!!
>


You apparently have indirectly included <linux/time.h> without including
a prerequisite file that defines something needed by this header file.

--

Fletcher Glenn

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com