nginx编译报错src/core/ngx_murmurhash.c:37:11: 错误:this statement may fall through [-Werror=implicit-fallthrough=] h ^= data[2]

报错信息如下

make -f objs/Makefile
make[1]: 进入目录“/opt/nginx-1.8.1”
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/ngx_murmurhash.o \
        src/core/ngx_murmurhash.c
src/core/ngx_murmurhash.c: 在函数‘ngx_murmur_hash2’中:
src/core/ngx_murmurhash.c:37:11: 错误:this statement may fall through [-Werror=implicit-fallthrough=]
         h ^= data[2] << 16;
         ~~^~~~~~~~~~~~~~~~
src/core/ngx_murmurhash.c:38:5: 附注:here
     case 2:
     ^~~~
src/core/ngx_murmurhash.c:39:11: 错误:this statement may fall through [-Werror=implicit-fallthrough=]
         h ^= data[1] << 8;
         ~~^~~~~~~~~~~~~~~
src/core/ngx_murmurhash.c:40:5: 附注:here
     case 1:
     ^~~~
cc1:所有的警告都被当作是错误
make[1]: *** [objs/Makefile:431:objs/src/core/ngx_murmurhash.o] 错误 1
make[1]: 离开目录“/opt/nginx-1.8.1”
make: *** [Makefile:8:build] 错误 2

原因:将警告当成错误处理

解决错误1:进入到nginx-1.6.3目录下(解压的目录)

找到当前目录下找到objs文件夹,并进入,打开文件Makefile,找到有一下内容的这行:

[root@lnmp nginx-1.8.1]# vim objs/Makefile
CFLAGS =  -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g 

-Werror: gcc将所有的警告当成错误进行处理把这行内容中的 “-Werror”去掉

摘自:https://bbs.cnbugs.com/read-37-1.html

感谢分享

 

  

posted @ 2020-09-19 16:04  Mr丶点心  阅读(14072)  评论(2编辑  收藏  举报