kcode
September 29th, 2008, 08:02 PM
Thats hello.c code, which i compiled(as root) using the following command
gcc -c -Wall -D_KERNEL_ -DMODULE -I /usr/src/linux-headers-2.6.24-18/include hello.c,
define MODULE
#include <linux/module.h>
int init_module (void)
{
printk("Hello kernel\n");
return 0;
}
void cleanup_module (void)
{
printk("goodbye kernel\n");
}
with error:
hello.c:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before numeric constant
In file included from /usr/src/linux-headers-2.6.24-18/include/linux/module.h:9,
from hello.c:2:
/usr/src/linux-headers-2.6.24-18/include/linux/list.h:995:2: warning: #warning "don't include kernel headers in userspace"
In file included from /usr/src/linux-headers-2.6.24-18/include/linux/module.h:12,
from hello.c:2:
/usr/src/linux-headers-2.6.24-18/include/linux/cache.h:5:23: error: asm/cache.h: No such file or directory
In file included from /usr/src/linux-headers-2.6.24-18/include/linux/module.h:14,
from hello.c:2:
/usr/src/linux-headers-2.6.24-18/include/linux/elf.h:396: error: expected declaration specifiers or ‘...’ before ‘loff_t’
In file included from /usr/src/linux-headers-2.6.24-18/include/linux/module.h:18,
from hello.c:2:
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:103: error: expected declaration specifiers or ‘...’ before numeric constant
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:103: error: expected declaration specifiers or ‘...’ before numeric constant
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h: In function ‘__printf’:
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:103: error: expected declaration specifiers before ‘__mark_check_format’
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:107: error: storage class specified for parameter ‘__mark_empty_function’
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:114: error: storage class specified for parameter ‘marker_probe_register’
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:119: error: storage class specified for parameter ‘marker_probe_unregister’
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:123: error: storage class specified for parameter ‘marker_probe_unregister_private_data’
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:125: error: storage class specified for parameter ‘marker_arm’
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:126: error: storage class specified for parameter ‘marker_disarm’
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:127: error: storage class specified for parameter ‘marker_get_private_data’
In file included from hello.c:2:
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:19:23: error: asm/local.h: No such file or directory
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:21:24: error: asm/module.h: No such file or directory
In file included from hello.c:2:
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:37: warning: empty declaration
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:43: warning: empty declaration
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:45: warning: empty declaration
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:48: error: field ‘attr’ has incomplete type
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:49: error: expected specifier-qualifier-list before ‘ssize_t’
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:55: warning: empty declaration
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:59: error: field ‘kobj’ has incomplete type
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:62: warning: empty declaration
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:65: error: storage class specified for parameter ‘init_module’
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:66: error: storage class specified for parameter ‘cleanup_module’
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:69: warning: empty declaration
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:84: error: storage class specified for parameter ‘__this_module’
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:165: warning: empty declaration
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:477: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:483: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:489: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:494: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:504: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:508: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:513: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:523: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:528: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:533: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:540: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:545: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:550: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:556: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:563: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:568: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:573: warning: empty declaration
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:589: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:596: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:601: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:606: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:618: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:621: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
hello.c:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
hello.c:11: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
hello.c:13:2: warning: no newline at end of file
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:163: error: declaration for parameter ‘search_exception_tables’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:84: error: parameter ‘__this_module’ has incomplete type
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:84: error: declaration for parameter ‘__this_module’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:77: error: declaration for parameter ‘sort_main_extable’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:76: error: declaration for parameter ‘sort_extable’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:74: error: declaration for parameter ‘search_extable’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:66: error: declaration for parameter ‘cleanup_module’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:65: error: declaration for parameter ‘init_module’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:127: error: declaration for parameter ‘marker_get_private_data’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:126: error: declaration for parameter ‘marker_disarm’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:125: error: declaration for parameter ‘marker_arm’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:123: error: declaration for parameter ‘marker_probe_unregister_private_data’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:119: error: declaration for parameter ‘marker_probe_unregister’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:114: error: declaration for parameter ‘marker_probe_register’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:107: error: declaration for parameter ‘__mark_empty_function’ but no such parameter
hello.c:13: error: expected ‘{’ at end of input
thanks
gcc -c -Wall -D_KERNEL_ -DMODULE -I /usr/src/linux-headers-2.6.24-18/include hello.c,
define MODULE
#include <linux/module.h>
int init_module (void)
{
printk("Hello kernel\n");
return 0;
}
void cleanup_module (void)
{
printk("goodbye kernel\n");
}
with error:
hello.c:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before numeric constant
In file included from /usr/src/linux-headers-2.6.24-18/include/linux/module.h:9,
from hello.c:2:
/usr/src/linux-headers-2.6.24-18/include/linux/list.h:995:2: warning: #warning "don't include kernel headers in userspace"
In file included from /usr/src/linux-headers-2.6.24-18/include/linux/module.h:12,
from hello.c:2:
/usr/src/linux-headers-2.6.24-18/include/linux/cache.h:5:23: error: asm/cache.h: No such file or directory
In file included from /usr/src/linux-headers-2.6.24-18/include/linux/module.h:14,
from hello.c:2:
/usr/src/linux-headers-2.6.24-18/include/linux/elf.h:396: error: expected declaration specifiers or ‘...’ before ‘loff_t’
In file included from /usr/src/linux-headers-2.6.24-18/include/linux/module.h:18,
from hello.c:2:
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:103: error: expected declaration specifiers or ‘...’ before numeric constant
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:103: error: expected declaration specifiers or ‘...’ before numeric constant
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h: In function ‘__printf’:
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:103: error: expected declaration specifiers before ‘__mark_check_format’
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:107: error: storage class specified for parameter ‘__mark_empty_function’
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:114: error: storage class specified for parameter ‘marker_probe_register’
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:119: error: storage class specified for parameter ‘marker_probe_unregister’
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:123: error: storage class specified for parameter ‘marker_probe_unregister_private_data’
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:125: error: storage class specified for parameter ‘marker_arm’
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:126: error: storage class specified for parameter ‘marker_disarm’
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:127: error: storage class specified for parameter ‘marker_get_private_data’
In file included from hello.c:2:
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:19:23: error: asm/local.h: No such file or directory
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:21:24: error: asm/module.h: No such file or directory
In file included from hello.c:2:
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:37: warning: empty declaration
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:43: warning: empty declaration
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:45: warning: empty declaration
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:48: error: field ‘attr’ has incomplete type
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:49: error: expected specifier-qualifier-list before ‘ssize_t’
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:55: warning: empty declaration
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:59: error: field ‘kobj’ has incomplete type
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:62: warning: empty declaration
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:65: error: storage class specified for parameter ‘init_module’
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:66: error: storage class specified for parameter ‘cleanup_module’
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:69: warning: empty declaration
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:84: error: storage class specified for parameter ‘__this_module’
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:165: warning: empty declaration
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:477: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:483: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:489: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:494: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:504: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:508: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:513: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:523: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:528: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:533: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:540: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:545: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:550: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:556: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:563: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:568: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:573: warning: empty declaration
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:589: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:596: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:601: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:606: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:618: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:621: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
hello.c:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
hello.c:11: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
hello.c:13:2: warning: no newline at end of file
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:163: error: declaration for parameter ‘search_exception_tables’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:84: error: parameter ‘__this_module’ has incomplete type
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:84: error: declaration for parameter ‘__this_module’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:77: error: declaration for parameter ‘sort_main_extable’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:76: error: declaration for parameter ‘sort_extable’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:74: error: declaration for parameter ‘search_extable’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:66: error: declaration for parameter ‘cleanup_module’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/module.h:65: error: declaration for parameter ‘init_module’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:127: error: declaration for parameter ‘marker_get_private_data’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:126: error: declaration for parameter ‘marker_disarm’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:125: error: declaration for parameter ‘marker_arm’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:123: error: declaration for parameter ‘marker_probe_unregister_private_data’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:119: error: declaration for parameter ‘marker_probe_unregister’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:114: error: declaration for parameter ‘marker_probe_register’ but no such parameter
/usr/src/linux-headers-2.6.24-18/include/linux/marker.h:107: error: declaration for parameter ‘__mark_empty_function’ but no such parameter
hello.c:13: error: expected ‘{’ at end of input
thanks