繁体   English   中英

没有 -Wdeclaration-after-statement 的 PostgreSQL C 扩展

[英]PostgreSQL C Extensions without -Wdeclaration-after-statement

目前,当我编译我的扩展时,我得到,

warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
   57 |  uint32 n = fctx->n;

PostgreSQL 当前在编译期间使用-Wdeclaration-after-statement 他们在我的机器上的pgxs全局 make 文件中专门设置了这个选项,

/usr/lib/postgresql/13/lib/pgxs/src/Makefile.global

它是用他们的CFLAGS设置的,

CFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer

无论如何要禁用-Wdeclaration-after-statement还是每个 PostgreSQL 扩展作者都必须采用相同的约定? 我可以在我的扩展中覆盖 CFLAGS 吗?

可能您可以通过链接中描述的说明覆盖它

变量PG_CFLAGS将被附加到CFLAGS ,所以只需添加-Wno-declaration-after-statement

我能够通过结束我的扩展的Makefile来消除这些警告,

$(OBJS): CFLAGS += $(PERMIT_DECLARATION_AFTER_STATEMENT)

感谢 RhodiumToad 在ircs://irc.libera.chat:6697/#postgresql ,他继续说

配置测试-Wno-declaration-after-statement有效并相应地设置该变量实际上我认为它会检查-Wdeclaration-after-statement ,如果有效,则假设 -Wno-... 也有效,您可以放置该规则在包含$(PGXS) ,如果需要或以定义PERMIT_DECLARATION_AFTER_STATEMENT为条件,您可以使其以$(MAJORVERSION)为条件

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM