Linux.com

atomic.h issue in Ubuntu 9.4

Link to this post 24 Nov 10

I can't compile atomic.h in Ubuntu 9.4, below is source code:

#include <stdio.h>
#include <stdlib.h>

#include <asm/atomic.h>

int main(void) {
puts("!!!Hello World!!!");
return EXIT_SUCCESS;
}

the following is the error info:
/usr/src/linux-headers-2.6.28-11/arch/x86/include/asm/alternative.h:45: 错误: expected specifier-qualifier-list before ‘u8'

Can anyone help me?

Link to this post 24 Nov 10

after using __KERNEL__, 'u8' can be found, but it occurred other errors:

gcc -DCONFIG_X86_32 -D__KERNEL__ -I/usr/src/linux-headers-2.6.28-11/include -I/usr/src/linux-headers-2.6.28-11/arch/x86/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/test_atomic.d" -MT"src/test_atomic.d" -o"src/test_atomic.o" "../src/test_atomic.c"

/usr/src/linux-headers-2.6.28-11/include/linux/log2.h:52: 错误: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘is_power_of_2’
In file included from /usr/src/linux-headers-2.6.28-11/arch/x86/include/asm/system.h:10,
from /usr/src/linux-headers-2.6.28-11/arch/x86/include/asm/processor.h:17,
from /usr/src/linux-headers-2.6.28-11/arch/x86/include/asm/atomic_32.h:5,
from /usr/src/linux-headers-2.6.28-11/arch/x86/include/asm/atomic.h:2,
from ../src/test_atomic.c:14:
/usr/src/linux-headers-2.6.28-11/include/linux/kernel.h:236: 错误: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘printk_timed_ratelimit’
/usr/src/linux-headers-2.6.28-11/include/linux/kernel.h:303: 错误: expected declaration specifiers or ‘...’ before ‘bool’
/usr/src/linux-headers-2.6.28-11/include/linux

Link to this post 03 Dec 10

Kernel code has no main() function. Please do some reading on kernel module development before you try to mung your system...

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board