首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Gcc编译: Bitops.h错误:预期“=”、“asm”或“__attribute__”

Gcc编译: Bitops.h错误:预期“=”、“asm”或“__attribute__”
EN

Stack Overflow用户
提问于 2017-05-23 06:36:25
回答 1查看 585关注 0票数 0

我试着用gcc建立一个文件。它包括互斥。

Makefile:

代码语言:javascript
运行
复制
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) 

当我给出,我得到以下错误。

错误:

代码语言:javascript
运行
复制
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行是下面代码段的第一行。

代码语言:javascript
运行
复制
static __always_inline int
test_and_set_bit_lock(long nr, volatile unsigned long *addr)
{
        return test_and_set_bit(nr, addr);
}

对于这种函数定义,我没有发现任何不正确的地方。

如果我在我的Makefile中遗漏了什么,请给我一些提示。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-05-23 06:45:49

代码语言:javascript
运行
复制
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原子结构作为更兼容的替代方案。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44127438

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档