nginx报错:src/core/ngx_murmurhash.c:39:11: error: this statement may fall through [-Werror=implicit-fa

本文详细描述了在编译Nginx过程中遇到的错误,特别是与ngx_murmurhash.c文件中ngx_murmur_hash2函数有关的警告被视为错误的问题。通过去除Makefile中的-Werror选项,成功解决了编译失败的情况。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

报错:

make -f objs/Makefile install
make[1]: Entering directory '/usr/local/nginx/nginx-1.7.7'
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: In function ‘ngx_murmur_hash2’:
src/core/ngx_murmurhash.c:37:11: error: this statement may fall through [-Werror=implicit-fallthrough=]
         h ^= data[2] << 16;
         ~~^~~~~~~~~~~~~~~~
src/core/ngx_murmurhash.c:38:5: note: here
     case 2:
     ^~~~
src/core/ngx_murmurhash.c:39:11: error: this statement may fall through [-Werror=implicit-fallthrough=]
         h ^= data[1] << 8;
         ~~^~~~~~~~~~~~~~~
src/core/ngx_murmurhash.c:40:5: note: here
     case 1:
     ^~~~
cc1: all warnings being treated as errors
objs/Makefile:439: recipe for target 'objs/src/core/ngx_murmurhash.o' failed
make[1]: *** [objs/src/core/ngx_murmurhash.o] Error 1
make[1]: Leaving directory '/usr/local/nginx/nginx-1.7.7'
Makefile:12: recipe for target 'install' failed
make: *** [install] Error 2

解决:

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

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

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

	
CFLAGS =  -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  


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

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值