我试着用gcc建立一个文件。它包括互斥。
Makefile:
CC = gcc
CFLAGS = -I/usr/src/linux-headers-3.13.0-32/include
CFLAGS += -I/usr/src/linux-headers-3.13.0-32/arch/x86/include
SOURCES := $(wildcard *.c)
all: $(SOURCES)
$(CC) $(CFLAGS) $(SOURCES)
当我给出,我得到以下错误。
错误:
gcc -I/usr/src/linux-headers-3.13.0-32/include -I/usr/src/linux-headers-3.13.0-32/arch/x86/include app.c rtos.c
In file included from /usr/src/linux-headers-3.13.0-32/include/linux/bitops.h:33:0,
from /usr/src/linux-headers-3.13.0-32/include/linux/kernel.h:10,
from /usr/src/linux-headers-3.13.0-32/arch/x86/include/asm/percpu.h:44,
from /usr/src/linux-headers-3.13.0-32/arch/x86/include/asm/current.h:5,
from /usr/src/linux-headers-3.13.0-32/include/linux/mutex.h:13,
from rtos.c:55:
/usr/src/linux-headers-3.13.0-32/arch/x86/include/asm/bitops.h:70:24: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
/usr/src/linux-headers-3.13.0-32/arch/x86/include/asm/bitops.h:108:24: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
/usr/src/linux-headers-3.13.0-32/arch/x86/include/asm/bitops.h:218:24: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int’
/usr/src/linux-headers-3.13.0-32/arch/x86/include/asm/bitops.h:310:24: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int’
/usr/src/linux-headers-3.13.0-32/arch/x86/include/asm/bitops.h,中显示错误的第218行是下面代码段的第一行。
static __always_inline int
test_and_set_bit_lock(long nr, volatile unsigned long *addr)
{
return test_and_set_bit(nr, addr);
}
对于这种函数定义,我没有发现任何不正确的地方。
如果我在我的Makefile中遗漏了什么,请给我一些提示。
发布于 2017-05-23 06:45:49
CFLAGS = -I/usr/src/linux-headers-3.13.0-32/include
CFLAGS += -I/usr/src/linux-headers-3.13.0-32/arch/x86/include
别干那事。
这些标头用于Linux内核和内核模块中。它们不适合在用户空间应用程序中使用。
根据您需要的原子操作,您可能可以使用GCC原子结构作为更兼容的替代方案。
https://stackoverflow.com/questions/44127438
复制相似问题