log2.h:22:1: error: ignoring attribute ‘noreturn’ because it it conflicts with attribute ‘const’ [-

include/linux/log2.h:19:1warningignoring attribute ‘noreturn’ because it conflicts with attribute ‘const’ [-Wattributes

类似这种错误是gcc版本需要降级

不小心下载了gcc的9.3.0版本,但是与工作上一些不兼容,故需要降低gcc版本为7.5.0

步骤如下:
1、下载需要的版本 apt install gcc-7

2、等待下载安装完成

3、进入bin目录 cd /usr/bin

4、删除gcc rm gcc

5、将自己需要版本投到gcc ln -s gcc-7 gcc

6、验证 gcc -v

则修改为了自己想要的gcc版本 380 

然后还是一样报错,需要将kernel或者common下的Makefile 将KBUILD_CFLAGS的 -Werror去掉如下
 381 KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
 382                    -fno-strict-aliasing -fno-common \
 383                    -Werror-implicit-function-declaration \
 384                    -Wno-format-security \
 385                    -fno-delete-null-pointer-checks \
 386                    -Werror
 387 KBUILD_CFLAGS   += -Wno-error=cpp
 388 KBUILD_AFLAGS_KERNEL :=
 389 KBUILD_CFLAGS_KERNEL :=
 390 KBUILD_AFLAGS   := -D__ASSEMBLY__
 391 KBUILD_AFLAGS_MODULE  := -DMODULE
 392 KBUILD_CFLAGS_MODULE  := -DMODULE
 393 KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds

猜你喜欢

转载自blog.csdn.net/liushengdi110/article/details/130681605
今日推荐