Hi,

On Wed, Mar 18, 2026 at 01:03:03PM -0400, Tom Lane wrote:
> Nazir Bilal Yavuz <[email protected]> writes:
> > I got this warning while running headerscheck after this commit:

Thanks for the report!

> > ~/Desktop/projects/postgres/src/interfaces/ecpg/ecpglib/ecpglib_extern.h:221:40:
> > warning: function declaration isn’t a prototype [-Wstrict-prototypes]
> >   221 | void            ecpg_init_sqlca(struct sqlca_t *sqlca)
> 
> Yeah, I see that too.  I believe the problem is that headerscheck
> doesn't cause POSTGRES_ECPG_INTERNAL to become defined, so that
> what the compiler is seeing is (from sqlca.h):
> 
>       #ifndef POSTGRES_ECPG_INTERNAL
>       #define sqlca (*ECPGget_sqlca())
>       #endif
> 
> and then
> 
>       void            ecpg_init_sqlca(struct sqlca_t *sqlca);

Oh right, confirmed with:

"
$ gcc -E -I src/interfaces/ecpg/include -I src/include -I src/interfaces/libpq 
\ 
    -include src/include/postgres_fe.h 
src/interfaces/ecpg/ecpglib/ecpglib_extern.h \
     | grep ECPGget_sqlca

$ struct sqlca_t *ECPGget_sqlca(void);
$ void ecpg_init_sqlca(struct sqlca_t *(*ECPGget_sqlca()));
"
> Kinda surprising that that's not a syntax error.

Yeah...

> We could plausibly fix this either by
> 
> (1) renaming ecpg_init_sqlca's parameter to something else;
> 
> (2) ensuring that POSTGRES_ECPG_INTERNAL is defined.  I'd be inclined
> to make ecpglib_extern.h do that rather than expecting headerscheck
> to know about it.
> 
> Neither of these options are beautiful, but perhaps #1 is slightly
> less ugly.  Any preferences?

I'd vote for #1 too, done in the attached.

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
>From aaf387275e52f14f876b6fd8895f4e9158a7f9ec Mon Sep 17 00:00:00 2001
From: Bertrand Drouvot <[email protected]>
Date: Wed, 18 Mar 2026 18:31:08 +0000
Subject: [PATCH v1] Fix -Wstrict-prototypes warning in ecpg_init_sqlca()
 declaration

When headerscheck compiles ecpglib_extern.h, POSTGRES_ECPG_INTERNAL is
not defined, causing sqlca.h to expand "sqlca" as a macro
(*ECPGget_sqlca()).  This causes the ecpg_init_sqlca() declaration to trigger
a -Wstrict-prototypes warning.

Fix by renaming the parameter from "sqlca" to "sqlca_p" in both the
declaration and definition, avoiding the macro expansion.

Author: Bertrand Drouvot <[email protected]>
Reported-by: Nazir Bilal Yavuz <[email protected]>
Diagnosed-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/CAN55FZ1VDwJ-ZD092ChYf%2B%2BhuP%2B-S3Cg45tJ8jNH5wx2c4BHAg%40mail.gmail.com
---
 src/interfaces/ecpg/ecpglib/ecpglib_extern.h | 2 +-
 src/interfaces/ecpg/ecpglib/misc.c           | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
 100.0% src/interfaces/ecpg/ecpglib/

diff --git a/src/interfaces/ecpg/ecpglib/ecpglib_extern.h b/src/interfaces/ecpg/ecpglib/ecpglib_extern.h
index bea1398fce8..c92f0aa1081 100644
--- a/src/interfaces/ecpg/ecpglib/ecpglib_extern.h
+++ b/src/interfaces/ecpg/ecpglib/ecpglib_extern.h
@@ -218,7 +218,7 @@ void		ecpg_log(const char *format,...) pg_attribute_printf(1, 2);
 bool		ecpg_auto_prepare(int lineno, const char *connection_name,
 							  const int compat, char **name, const char *query);
 bool		ecpg_register_prepared_stmt(struct statement *stmt);
-void		ecpg_init_sqlca(struct sqlca_t *sqlca);
+void		ecpg_init_sqlca(struct sqlca_t *sqlca_p);
 
 struct sqlda_compat *ecpg_build_compat_sqlda(int line, PGresult *res, int row,
 											 enum COMPAT_MODE compat);
diff --git a/src/interfaces/ecpg/ecpglib/misc.c b/src/interfaces/ecpg/ecpglib/misc.c
index 1885732a652..40ea174ae9f 100644
--- a/src/interfaces/ecpg/ecpglib/misc.c
+++ b/src/interfaces/ecpg/ecpglib/misc.c
@@ -64,9 +64,9 @@ static volatile int simple_debug = 0;
 static FILE *debugstream = NULL;
 
 void
-ecpg_init_sqlca(struct sqlca_t *sqlca)
+ecpg_init_sqlca(struct sqlca_t *sqlca_p)
 {
-	memcpy(sqlca, &sqlca_init, sizeof(struct sqlca_t));
+	memcpy(sqlca_p, &sqlca_init, sizeof(struct sqlca_t));
 }
 
 bool
-- 
2.34.1

Reply via email to