Hi hackers,

PFA a patch to $SUBJECT. The idea is to avoid having to chase those warnings
manually like 11171fe1fc8, cdf4b9aff2, 0e72b9d440, 7069dbcc31, f1283ed6cc,
7b66e2c086, e95126cf04 and 9f7c527af3 have done.

The idea has been discussed in [1] and [2].

The patch is divided in 2 parts:

0001: Prevent -Wstrict-prototypes and -Wold-style-definition warnings

It fixes the remaining warnings that those new flags would generate.

0002: Enable -Wstrict-prototypes and -Wold-style-definition by default

Those are available in all gcc and clang versions that support C11 and as C11
is required as of f5e0186f865c, then we can add them without capability test.

The new flags are moved in configure.ac late enough to avoid any error (for
example, PGAC_PRINTF_ARCHETYPE which uses -Werror and would fail to detect
gnu_printf if -Wstrict-prototypes is active) leading to mingw_cross_warning CI
task failing.

Also, readline headers trigger a lot of warnings with -Wstrict-prototypes, so
we make use of the system_header pragma to hide the warnings (as discussed in
[3].

[1]: https://postgr.es/m/262909b8-3f4b-42ce-acd7-bdd4a6897990%40eisentraut.org
[2]: 
https://postgr.es/m/aTJ9T8HyJN3D024w%40ip-10-97-1-34.eu-west-3.compute.internal
[3]: https://postgr.es/m/1049756.1764861448%40sss.pgh.pa.us

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
>From 8c44c5be1a68c0b2a35ac318f66c294afb6eda34 Mon Sep 17 00:00:00 2001
From: Bertrand Drouvot <[email protected]>
Date: Mon, 9 Mar 2026 09:57:02 +0000
Subject: [PATCH v1 1/2] Prevent -Wstrict-prototypes and -Wold-style-definition
 warnings

A following commit will enable -Wstrict-prototypes and -Wold-style-definition
by default. This commit fixes the warnings that those new flags will generate
before actually adding the new flags.

Author: Bertrand Drouvot <[email protected]>
Discussion: https://postgr.es/m/13d51b20-a69c-4ac1-8546-ec4fc278064f%40eisentraut.org
---
 src/interfaces/ecpg/test/compat_informix/intoasc.pgc          | 2 +-
 src/interfaces/ecpg/test/compat_oracle/char_array.pgc         | 2 +-
 src/interfaces/ecpg/test/expected/compat_informix-intoasc.c   | 2 +-
 src/interfaces/ecpg/test/expected/compat_oracle-char_array.c  | 2 +-
 src/interfaces/ecpg/test/expected/preproc-array_of_struct.c   | 2 +-
 src/interfaces/ecpg/test/expected/preproc-autoprep.c          | 2 +-
 src/interfaces/ecpg/test/expected/preproc-pointer_to_struct.c | 2 +-
 src/interfaces/ecpg/test/expected/sql-code100.c               | 2 +-
 src/interfaces/ecpg/test/expected/sql-copystdout.c            | 2 +-
 src/interfaces/ecpg/test/expected/sql-declare.c               | 4 ++--
 src/interfaces/ecpg/test/expected/sql-dyntest.c               | 2 +-
 src/interfaces/ecpg/test/expected/sql-fetch.c                 | 2 +-
 src/interfaces/ecpg/test/expected/sql-func.c                  | 2 +-
 src/interfaces/ecpg/test/expected/sql-indicators.c            | 2 +-
 src/interfaces/ecpg/test/expected/sql-insupd.c                | 2 +-
 src/interfaces/ecpg/test/expected/sql-parser.c                | 2 +-
 src/interfaces/ecpg/test/expected/sql-quote.c                 | 2 +-
 src/interfaces/ecpg/test/expected/sql-show.c                  | 2 +-
 src/interfaces/ecpg/test/expected/sql-sqljson.c               | 2 +-
 src/interfaces/ecpg/test/expected/sql-sqljson_jsontable.c     | 2 +-
 src/interfaces/ecpg/test/expected/thread-alloc.c              | 2 +-
 src/interfaces/ecpg/test/expected/thread-descriptor.c         | 2 +-
 src/interfaces/ecpg/test/expected/thread-prep.c               | 2 +-
 src/interfaces/ecpg/test/expected/thread-thread.c             | 2 +-
 src/interfaces/ecpg/test/expected/thread-thread_implicit.c    | 2 +-
 src/interfaces/ecpg/test/preproc/array_of_struct.pgc          | 2 +-
 src/interfaces/ecpg/test/preproc/autoprep.pgc                 | 2 +-
 src/interfaces/ecpg/test/preproc/pointer_to_struct.pgc        | 2 +-
 src/interfaces/ecpg/test/sql/code100.pgc                      | 2 +-
 src/interfaces/ecpg/test/sql/copystdout.pgc                   | 2 +-
 src/interfaces/ecpg/test/sql/declare.pgc                      | 4 ++--
 src/interfaces/ecpg/test/sql/dyntest.pgc                      | 2 +-
 src/interfaces/ecpg/test/sql/fetch.pgc                        | 2 +-
 src/interfaces/ecpg/test/sql/func.pgc                         | 2 +-
 src/interfaces/ecpg/test/sql/indicators.pgc                   | 2 +-
 src/interfaces/ecpg/test/sql/insupd.pgc                       | 2 +-
 src/interfaces/ecpg/test/sql/parser.pgc                       | 2 +-
 src/interfaces/ecpg/test/sql/quote.pgc                        | 2 +-
 src/interfaces/ecpg/test/sql/show.pgc                         | 2 +-
 src/interfaces/ecpg/test/sql/sqljson.pgc                      | 2 +-
 src/interfaces/ecpg/test/sql/sqljson_jsontable.pgc            | 2 +-
 src/interfaces/ecpg/test/thread/alloc.pgc                     | 2 +-
 src/interfaces/ecpg/test/thread/descriptor.pgc                | 2 +-
 src/interfaces/ecpg/test/thread/prep.pgc                      | 2 +-
 src/interfaces/ecpg/test/thread/thread.pgc                    | 2 +-
 src/interfaces/ecpg/test/thread/thread_implicit.pgc           | 2 +-
 src/interfaces/libpq/test/libpq_testclient.c                  | 2 +-
 47 files changed, 49 insertions(+), 49 deletions(-)
  48.3% src/interfaces/ecpg/test/expected/
   6.0% src/interfaces/ecpg/test/preproc/
  28.2% src/interfaces/ecpg/test/sql/
   9.8% src/interfaces/ecpg/test/thread/
   4.1% src/interfaces/ecpg/test/
   3.2% src/interfaces/libpq/test/

diff --git a/src/interfaces/ecpg/test/compat_informix/intoasc.pgc b/src/interfaces/ecpg/test/compat_informix/intoasc.pgc
index d13c83bb7a7..cf8b342ab4c 100644
--- a/src/interfaces/ecpg/test/compat_informix/intoasc.pgc
+++ b/src/interfaces/ecpg/test/compat_informix/intoasc.pgc
@@ -8,7 +8,7 @@ EXEC SQL BEGIN DECLARE SECTION;
     interval *interval_ptr;
 EXEC SQL END DECLARE SECTION;
 
-int main()
+int main(void)
 {
     interval_ptr = (interval *) malloc(sizeof(interval));
     interval_ptr->time = 100000000;
diff --git a/src/interfaces/ecpg/test/compat_oracle/char_array.pgc b/src/interfaces/ecpg/test/compat_oracle/char_array.pgc
index de18cbb57ff..303fe02aa27 100644
--- a/src/interfaces/ecpg/test/compat_oracle/char_array.pgc
+++ b/src/interfaces/ecpg/test/compat_oracle/char_array.pgc
@@ -17,7 +17,7 @@ static void warn(void)
    should be fixed-length, blank-padded, then null-terminated.
    Conforms to the ANSI Fixed Character type. */
 
-int main() {
+int main(void) {
 
   EXEC SQL WHENEVER SQLWARNING do warn();
   EXEC SQL WHENEVER SQLERROR STOP;
diff --git a/src/interfaces/ecpg/test/expected/compat_informix-intoasc.c b/src/interfaces/ecpg/test/expected/compat_informix-intoasc.c
index 30988809e92..56b927c6aae 100644
--- a/src/interfaces/ecpg/test/expected/compat_informix-intoasc.c
+++ b/src/interfaces/ecpg/test/expected/compat_informix-intoasc.c
@@ -27,7 +27,7 @@
 #line 9 "intoasc.pgc"
 
 
-int main()
+int main(void)
 {
     interval_ptr = (interval *) malloc(sizeof(interval));
     interval_ptr->time = 100000000;
diff --git a/src/interfaces/ecpg/test/expected/compat_oracle-char_array.c b/src/interfaces/ecpg/test/expected/compat_oracle-char_array.c
index 16db663dcc5..2daedb546c2 100644
--- a/src/interfaces/ecpg/test/expected/compat_oracle-char_array.c
+++ b/src/interfaces/ecpg/test/expected/compat_oracle-char_array.c
@@ -57,7 +57,7 @@ static void warn(void)
    should be fixed-length, blank-padded, then null-terminated.
    Conforms to the ANSI Fixed Character type. */
 
-int main() {
+int main(void) {
 
   /* exec sql whenever sql_warning  do warn ( ) ; */
 #line 22 "char_array.pgc"
diff --git a/src/interfaces/ecpg/test/expected/preproc-array_of_struct.c b/src/interfaces/ecpg/test/expected/preproc-array_of_struct.c
index bbe904fa106..31349aa5509 100644
--- a/src/interfaces/ecpg/test/expected/preproc-array_of_struct.c
+++ b/src/interfaces/ecpg/test/expected/preproc-array_of_struct.c
@@ -57,7 +57,7 @@ typedef  struct {
 #line 27 "array_of_struct.pgc"
 
 
-int main()
+int main(void)
 {
     /* exec sql begin declare section */
         
diff --git a/src/interfaces/ecpg/test/expected/preproc-autoprep.c b/src/interfaces/ecpg/test/expected/preproc-autoprep.c
index 8ed5a2ca2c1..9f811c200a9 100644
--- a/src/interfaces/ecpg/test/expected/preproc-autoprep.c
+++ b/src/interfaces/ecpg/test/expected/preproc-autoprep.c
@@ -248,7 +248,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 }
 
-int main() {
+int main(void) {
   test();
   test();     /* retry */
 
diff --git a/src/interfaces/ecpg/test/expected/preproc-pointer_to_struct.c b/src/interfaces/ecpg/test/expected/preproc-pointer_to_struct.c
index e59ace24f12..aa72604051f 100644
--- a/src/interfaces/ecpg/test/expected/preproc-pointer_to_struct.c
+++ b/src/interfaces/ecpg/test/expected/preproc-pointer_to_struct.c
@@ -58,7 +58,7 @@ typedef  struct {
 #line 28 "pointer_to_struct.pgc"
 
 
-int main()
+int main(void)
 {
     /* exec sql begin declare section */
               
diff --git a/src/interfaces/ecpg/test/expected/sql-code100.c b/src/interfaces/ecpg/test/expected/sql-code100.c
index 4c85530a17a..f05a9540b0e 100644
--- a/src/interfaces/ecpg/test/expected/sql-code100.c
+++ b/src/interfaces/ecpg/test/expected/sql-code100.c
@@ -92,7 +92,7 @@ struct sqlca_t *ECPGget_sqlca(void);
 
 
 
-int main()
+int main(void)
 {  /* exec sql begin declare section */
     
    
diff --git a/src/interfaces/ecpg/test/expected/sql-copystdout.c b/src/interfaces/ecpg/test/expected/sql-copystdout.c
index d2599fb0e93..f875036f478 100644
--- a/src/interfaces/ecpg/test/expected/sql-copystdout.c
+++ b/src/interfaces/ecpg/test/expected/sql-copystdout.c
@@ -96,7 +96,7 @@ struct sqlca_t *ECPGget_sqlca(void);
 
 
 int
-main ()
+main(void)
 {
   ECPGdebug (1, stderr);
 
diff --git a/src/interfaces/ecpg/test/expected/sql-declare.c b/src/interfaces/ecpg/test/expected/sql-declare.c
index 6248d992175..2a59313bf46 100644
--- a/src/interfaces/ecpg/test/expected/sql-declare.c
+++ b/src/interfaces/ecpg/test/expected/sql-declare.c
@@ -578,7 +578,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
     printf("count: %d, length: %d, data: %s\n", count, length, f3[0]);
 }
 
-void commitTable()
+void commitTable(void)
 {
     { ECPGtrans(__LINE__, "con1", "commit");
 #line 187 "declare.pgc"
@@ -597,7 +597,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 /*
  * reset all the output variables
  */
-void reset()
+void reset(void)
 {
     memset(f1, 0, sizeof(f1));
     memset(f2, 0, sizeof(f2));
diff --git a/src/interfaces/ecpg/test/expected/sql-dyntest.c b/src/interfaces/ecpg/test/expected/sql-dyntest.c
index 513d44c6304..8eccfbfc1b5 100644
--- a/src/interfaces/ecpg/test/expected/sql-dyntest.c
+++ b/src/interfaces/ecpg/test/expected/sql-dyntest.c
@@ -151,7 +151,7 @@ error (void)
 }
 
 int
-main ()
+main(void)
 {
   /* exec sql begin declare section */
    
diff --git a/src/interfaces/ecpg/test/expected/sql-fetch.c b/src/interfaces/ecpg/test/expected/sql-fetch.c
index ca7d14e97c4..0aea4a9192a 100644
--- a/src/interfaces/ecpg/test/expected/sql-fetch.c
+++ b/src/interfaces/ecpg/test/expected/sql-fetch.c
@@ -22,7 +22,7 @@
 #line 5 "fetch.pgc"
 
 
-int main() {
+int main(void) {
   /* exec sql begin declare section */
      
        
diff --git a/src/interfaces/ecpg/test/expected/sql-func.c b/src/interfaces/ecpg/test/expected/sql-func.c
index 17c5d26ea41..fa590bd16ca 100644
--- a/src/interfaces/ecpg/test/expected/sql-func.c
+++ b/src/interfaces/ecpg/test/expected/sql-func.c
@@ -22,7 +22,7 @@
 #line 5 "func.pgc"
 
 
-int main() {
+int main(void) {
   
 #line 8 "func.pgc"
  char text [ 25 ] ;
diff --git a/src/interfaces/ecpg/test/expected/sql-indicators.c b/src/interfaces/ecpg/test/expected/sql-indicators.c
index 7cf43ad6228..796bd906af6 100644
--- a/src/interfaces/ecpg/test/expected/sql-indicators.c
+++ b/src/interfaces/ecpg/test/expected/sql-indicators.c
@@ -91,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void);
 #line 4 "indicators.pgc"
 
 
-int main()
+int main(void)
 {
 	/* exec sql begin declare section */
 		   
diff --git a/src/interfaces/ecpg/test/expected/sql-insupd.c b/src/interfaces/ecpg/test/expected/sql-insupd.c
index 5f73bf566ff..dde2bdc9688 100644
--- a/src/interfaces/ecpg/test/expected/sql-insupd.c
+++ b/src/interfaces/ecpg/test/expected/sql-insupd.c
@@ -22,7 +22,7 @@
 #line 5 "insupd.pgc"
 
 
-int main() {
+int main(void) {
   /* exec sql begin declare section */
 	    
   
diff --git a/src/interfaces/ecpg/test/expected/sql-parser.c b/src/interfaces/ecpg/test/expected/sql-parser.c
index 32bb2c21260..ba53ab03309 100644
--- a/src/interfaces/ecpg/test/expected/sql-parser.c
+++ b/src/interfaces/ecpg/test/expected/sql-parser.c
@@ -23,7 +23,7 @@
 #line 6 "parser.pgc"
 
 
-int main() {
+int main(void) {
   /* exec sql begin declare section */
 	   
   
diff --git a/src/interfaces/ecpg/test/expected/sql-quote.c b/src/interfaces/ecpg/test/expected/sql-quote.c
index ddc1e90b1c3..3001df4069f 100644
--- a/src/interfaces/ecpg/test/expected/sql-quote.c
+++ b/src/interfaces/ecpg/test/expected/sql-quote.c
@@ -22,7 +22,7 @@
 #line 5 "quote.pgc"
 
 
-int main() {
+int main(void) {
   /* exec sql begin declare section */
      
       
diff --git a/src/interfaces/ecpg/test/expected/sql-show.c b/src/interfaces/ecpg/test/expected/sql-show.c
index f934dc99feb..f4add407439 100644
--- a/src/interfaces/ecpg/test/expected/sql-show.c
+++ b/src/interfaces/ecpg/test/expected/sql-show.c
@@ -22,7 +22,7 @@
 #line 5 "show.pgc"
 
 
-int main() {
+int main(void) {
   /* exec sql begin declare section */
        
   
diff --git a/src/interfaces/ecpg/test/expected/sql-sqljson.c b/src/interfaces/ecpg/test/expected/sql-sqljson.c
index 39221f9ea5d..be7fbe19e13 100644
--- a/src/interfaces/ecpg/test/expected/sql-sqljson.c
+++ b/src/interfaces/ecpg/test/expected/sql-sqljson.c
@@ -96,7 +96,7 @@ struct sqlca_t *ECPGget_sqlca(void);
 
 
 int
-main ()
+main(void)
 {
 /* exec sql begin declare section */
    
diff --git a/src/interfaces/ecpg/test/expected/sql-sqljson_jsontable.c b/src/interfaces/ecpg/test/expected/sql-sqljson_jsontable.c
index b2a0f11eb6e..cbbc99539cb 100644
--- a/src/interfaces/ecpg/test/expected/sql-sqljson_jsontable.c
+++ b/src/interfaces/ecpg/test/expected/sql-sqljson_jsontable.c
@@ -96,7 +96,7 @@ struct sqlca_t *ECPGget_sqlca(void);
 
 
 int
-main ()
+main(void)
 {
 /* exec sql begin declare section */
    
diff --git a/src/interfaces/ecpg/test/expected/thread-alloc.c b/src/interfaces/ecpg/test/expected/thread-alloc.c
index 3b31d27fd34..912d94c134c 100644
--- a/src/interfaces/ecpg/test/expected/thread-alloc.c
+++ b/src/interfaces/ecpg/test/expected/thread-alloc.c
@@ -179,7 +179,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 	return 0;
 }
 
-int main ()
+int main(void)
 {
 	intptr_t i;
 #ifdef WIN32
diff --git a/src/interfaces/ecpg/test/expected/thread-descriptor.c b/src/interfaces/ecpg/test/expected/thread-descriptor.c
index e34f4708d13..f9322b3e9bb 100644
--- a/src/interfaces/ecpg/test/expected/thread-descriptor.c
+++ b/src/interfaces/ecpg/test/expected/thread-descriptor.c
@@ -125,7 +125,7 @@ if (sqlca.sqlcode < 0) sqlprint();
 	return 0;
 }
 
-int main ()
+int main(void)
 {
 	int i;
 #ifdef WIN32
diff --git a/src/interfaces/ecpg/test/expected/thread-prep.c b/src/interfaces/ecpg/test/expected/thread-prep.c
index 052e27b634f..4fb19e3fd1c 100644
--- a/src/interfaces/ecpg/test/expected/thread-prep.c
+++ b/src/interfaces/ecpg/test/expected/thread-prep.c
@@ -189,7 +189,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 	return 0;
 }
 
-int main ()
+int main(void)
 {
 	intptr_t i;
 #ifdef WIN32
diff --git a/src/interfaces/ecpg/test/expected/thread-thread.c b/src/interfaces/ecpg/test/expected/thread-thread.c
index 95faa223c20..71da6f2e07d 100644
--- a/src/interfaces/ecpg/test/expected/thread-thread.c
+++ b/src/interfaces/ecpg/test/expected/thread-thread.c
@@ -38,7 +38,7 @@ void *test_thread(void *arg);
 int nthreads   = 10;
 int iterations = 20;
 
-int main()
+int main(void)
 {
 #ifndef WIN32
   pthread_t *threads;
diff --git a/src/interfaces/ecpg/test/expected/thread-thread_implicit.c b/src/interfaces/ecpg/test/expected/thread-thread_implicit.c
index 7ac0297a234..259fc09dad6 100644
--- a/src/interfaces/ecpg/test/expected/thread-thread_implicit.c
+++ b/src/interfaces/ecpg/test/expected/thread-thread_implicit.c
@@ -38,7 +38,7 @@ void *test_thread(void *arg);
 int nthreads   = 10;
 int iterations = 20;
 
-int main()
+int main(void)
 {
 #ifndef WIN32
   pthread_t *threads;
diff --git a/src/interfaces/ecpg/test/preproc/array_of_struct.pgc b/src/interfaces/ecpg/test/preproc/array_of_struct.pgc
index dff9f9a7471..7cc76075536 100644
--- a/src/interfaces/ecpg/test/preproc/array_of_struct.pgc
+++ b/src/interfaces/ecpg/test/preproc/array_of_struct.pgc
@@ -26,7 +26,7 @@ EXEC SQL TYPE company IS
         customer customers[10];
     };
 
-int main()
+int main(void)
 {
     EXEC SQL begin declare section;
       customer  custs1[10];
diff --git a/src/interfaces/ecpg/test/preproc/autoprep.pgc b/src/interfaces/ecpg/test/preproc/autoprep.pgc
index d3d9305da5b..6da232d59ab 100644
--- a/src/interfaces/ecpg/test/preproc/autoprep.pgc
+++ b/src/interfaces/ecpg/test/preproc/autoprep.pgc
@@ -64,7 +64,7 @@ static void test(void) {
   EXEC SQL DISCONNECT ALL;
 }
 
-int main() {
+int main(void) {
   test();
   test();     /* retry */
 
diff --git a/src/interfaces/ecpg/test/preproc/pointer_to_struct.pgc b/src/interfaces/ecpg/test/preproc/pointer_to_struct.pgc
index 6003f0fa183..46404373ce6 100644
--- a/src/interfaces/ecpg/test/preproc/pointer_to_struct.pgc
+++ b/src/interfaces/ecpg/test/preproc/pointer_to_struct.pgc
@@ -27,7 +27,7 @@ EXEC SQL TYPE company IS
         customer *customers;
     };
 
-int main()
+int main(void)
 {
     EXEC SQL begin declare section;
       customer  *custs1 = (customer *) malloc(sizeof(customer) * 10);
diff --git a/src/interfaces/ecpg/test/sql/code100.pgc b/src/interfaces/ecpg/test/sql/code100.pgc
index d9a5e52444a..8b29b0a9d2c 100644
--- a/src/interfaces/ecpg/test/sql/code100.pgc
+++ b/src/interfaces/ecpg/test/sql/code100.pgc
@@ -4,7 +4,7 @@ exec sql include sqlca;
 exec sql include ../regression;
 
 
-int main()
+int main(void)
 {  exec sql begin declare section;
    int index;
    exec sql end declare section;
diff --git a/src/interfaces/ecpg/test/sql/copystdout.pgc b/src/interfaces/ecpg/test/sql/copystdout.pgc
index 9ecce7d42c2..f385a86f2ad 100644
--- a/src/interfaces/ecpg/test/sql/copystdout.pgc
+++ b/src/interfaces/ecpg/test/sql/copystdout.pgc
@@ -6,7 +6,7 @@ exec sql include ../regression;
 EXEC SQL WHENEVER SQLERROR sqlprint;
 
 int
-main ()
+main(void)
 {
   ECPGdebug (1, stderr);
 
diff --git a/src/interfaces/ecpg/test/sql/declare.pgc b/src/interfaces/ecpg/test/sql/declare.pgc
index e7ee4aa5348..4dfe1dd8bd3 100644
--- a/src/interfaces/ecpg/test/sql/declare.pgc
+++ b/src/interfaces/ecpg/test/sql/declare.pgc
@@ -182,7 +182,7 @@ void execute_test(void)
     printf("count: %d, length: %d, data: %s\n", count, length, f3[0]);
 }
 
-void commitTable()
+void commitTable(void)
 {
     EXEC SQL AT con1 COMMIT;
     EXEC SQL AT con2 COMMIT;
@@ -191,7 +191,7 @@ void commitTable()
 /*
  * reset all the output variables
  */
-void reset()
+void reset(void)
 {
     memset(f1, 0, sizeof(f1));
     memset(f2, 0, sizeof(f2));
diff --git a/src/interfaces/ecpg/test/sql/dyntest.pgc b/src/interfaces/ecpg/test/sql/dyntest.pgc
index 0222c898515..f7cc7293323 100644
--- a/src/interfaces/ecpg/test/sql/dyntest.pgc
+++ b/src/interfaces/ecpg/test/sql/dyntest.pgc
@@ -16,7 +16,7 @@ error (void)
 }
 
 int
-main ()
+main(void)
 {
   exec sql begin declare section;
   int COUNT;
diff --git a/src/interfaces/ecpg/test/sql/fetch.pgc b/src/interfaces/ecpg/test/sql/fetch.pgc
index 31e525e42d4..6367cdb8727 100644
--- a/src/interfaces/ecpg/test/sql/fetch.pgc
+++ b/src/interfaces/ecpg/test/sql/fetch.pgc
@@ -4,7 +4,7 @@
 
 EXEC SQL INCLUDE ../regression;
 
-int main() {
+int main(void) {
   EXEC SQL BEGIN DECLARE SECTION;
     char str[25];
     int i, count=1, loopcount;
diff --git a/src/interfaces/ecpg/test/sql/func.pgc b/src/interfaces/ecpg/test/sql/func.pgc
index 5ebcafa11da..fcc2632c3de 100644
--- a/src/interfaces/ecpg/test/sql/func.pgc
+++ b/src/interfaces/ecpg/test/sql/func.pgc
@@ -4,7 +4,7 @@
 
 EXEC SQL INCLUDE ../regression;
 
-int main() {
+int main(void) {
   EXEC SQL char text[25];
 
   ECPGdebug(1, stderr);
diff --git a/src/interfaces/ecpg/test/sql/indicators.pgc b/src/interfaces/ecpg/test/sql/indicators.pgc
index c1f26e33adc..d925faf35ce 100644
--- a/src/interfaces/ecpg/test/sql/indicators.pgc
+++ b/src/interfaces/ecpg/test/sql/indicators.pgc
@@ -3,7 +3,7 @@
 exec sql include sqlca;
 exec sql include ../regression;
 
-int main()
+int main(void)
 {
 	exec sql begin declare section;
 		int intvar = 5;
diff --git a/src/interfaces/ecpg/test/sql/insupd.pgc b/src/interfaces/ecpg/test/sql/insupd.pgc
index b12f66f791a..50dac5e5f1f 100644
--- a/src/interfaces/ecpg/test/sql/insupd.pgc
+++ b/src/interfaces/ecpg/test/sql/insupd.pgc
@@ -4,7 +4,7 @@
 
 EXEC SQL INCLUDE ../regression;
 
-int main() {
+int main(void) {
   EXEC SQL BEGIN DECLARE SECTION;
 	int i1[3], i2[3], i3[3], i4;
   EXEC SQL END DECLARE SECTION;
diff --git a/src/interfaces/ecpg/test/sql/parser.pgc b/src/interfaces/ecpg/test/sql/parser.pgc
index 6e15f1364d5..ab2655b755c 100644
--- a/src/interfaces/ecpg/test/sql/parser.pgc
+++ b/src/interfaces/ecpg/test/sql/parser.pgc
@@ -5,7 +5,7 @@
 /* test parser addition that merges two tokens into one */
 EXEC SQL INCLUDE ../regression;
 
-int main() {
+int main(void) {
   EXEC SQL BEGIN DECLARE SECTION;
 	int item[3], ind[3], i;
   EXEC SQL END DECLARE SECTION;
diff --git a/src/interfaces/ecpg/test/sql/quote.pgc b/src/interfaces/ecpg/test/sql/quote.pgc
index 5cf4833d053..da42aab056d 100644
--- a/src/interfaces/ecpg/test/sql/quote.pgc
+++ b/src/interfaces/ecpg/test/sql/quote.pgc
@@ -4,7 +4,7 @@
 
 EXEC SQL INCLUDE ../regression;
 
-int main() {
+int main(void) {
   EXEC SQL BEGIN DECLARE SECTION;
     char var[25];
     int i, loopcount;
diff --git a/src/interfaces/ecpg/test/sql/show.pgc b/src/interfaces/ecpg/test/sql/show.pgc
index 232b3e77348..b1318453058 100644
--- a/src/interfaces/ecpg/test/sql/show.pgc
+++ b/src/interfaces/ecpg/test/sql/show.pgc
@@ -4,7 +4,7 @@
 
 EXEC SQL INCLUDE ../regression;
 
-int main() {
+int main(void) {
   EXEC SQL BEGIN DECLARE SECTION;
     char var[25] = "public";
   EXEC SQL END DECLARE SECTION;
diff --git a/src/interfaces/ecpg/test/sql/sqljson.pgc b/src/interfaces/ecpg/test/sql/sqljson.pgc
index ddcbcc3b3cb..6cc8a375dd5 100644
--- a/src/interfaces/ecpg/test/sql/sqljson.pgc
+++ b/src/interfaces/ecpg/test/sql/sqljson.pgc
@@ -6,7 +6,7 @@ exec sql include ../regression;
 EXEC SQL WHENEVER SQLERROR sqlprint;
 
 int
-main ()
+main(void)
 {
 EXEC SQL BEGIN DECLARE SECTION;
   char json[1024];
diff --git a/src/interfaces/ecpg/test/sql/sqljson_jsontable.pgc b/src/interfaces/ecpg/test/sql/sqljson_jsontable.pgc
index aa2b4494bb6..3e9a110944d 100644
--- a/src/interfaces/ecpg/test/sql/sqljson_jsontable.pgc
+++ b/src/interfaces/ecpg/test/sql/sqljson_jsontable.pgc
@@ -6,7 +6,7 @@ exec sql include ../regression;
 EXEC SQL WHENEVER SQLERROR sqlprint;
 
 int
-main ()
+main(void)
 {
 EXEC SQL BEGIN DECLARE SECTION;
   int foo;
diff --git a/src/interfaces/ecpg/test/thread/alloc.pgc b/src/interfaces/ecpg/test/thread/alloc.pgc
index d3d35493bf9..39faa6dc2ef 100644
--- a/src/interfaces/ecpg/test/thread/alloc.pgc
+++ b/src/interfaces/ecpg/test/thread/alloc.pgc
@@ -51,7 +51,7 @@ static void* fn(void* arg)
 	return 0;
 }
 
-int main ()
+int main(void)
 {
 	intptr_t i;
 #ifdef WIN32
diff --git a/src/interfaces/ecpg/test/thread/descriptor.pgc b/src/interfaces/ecpg/test/thread/descriptor.pgc
index 30bce7c87bc..b1485ac2a5c 100644
--- a/src/interfaces/ecpg/test/thread/descriptor.pgc
+++ b/src/interfaces/ecpg/test/thread/descriptor.pgc
@@ -32,7 +32,7 @@ static void* fn(void* arg)
 	return 0;
 }
 
-int main ()
+int main(void)
 {
 	int i;
 #ifdef WIN32
diff --git a/src/interfaces/ecpg/test/thread/prep.pgc b/src/interfaces/ecpg/test/thread/prep.pgc
index f61b31ce101..a389a6ae39e 100644
--- a/src/interfaces/ecpg/test/thread/prep.pgc
+++ b/src/interfaces/ecpg/test/thread/prep.pgc
@@ -51,7 +51,7 @@ static void* fn(void* arg)
 	return 0;
 }
 
-int main ()
+int main(void)
 {
 	intptr_t i;
 #ifdef WIN32
diff --git a/src/interfaces/ecpg/test/thread/thread.pgc b/src/interfaces/ecpg/test/thread/thread.pgc
index b9b9ebb441d..36ff91fe816 100644
--- a/src/interfaces/ecpg/test/thread/thread.pgc
+++ b/src/interfaces/ecpg/test/thread/thread.pgc
@@ -20,7 +20,7 @@ void *test_thread(void *arg);
 int nthreads   = 10;
 int iterations = 20;
 
-int main()
+int main(void)
 {
 #ifndef WIN32
   pthread_t *threads;
diff --git a/src/interfaces/ecpg/test/thread/thread_implicit.pgc b/src/interfaces/ecpg/test/thread/thread_implicit.pgc
index ff9b12a9437..711a8e26cc6 100644
--- a/src/interfaces/ecpg/test/thread/thread_implicit.pgc
+++ b/src/interfaces/ecpg/test/thread/thread_implicit.pgc
@@ -20,7 +20,7 @@ void *test_thread(void *arg);
 int nthreads   = 10;
 int iterations = 20;
 
-int main()
+int main(void)
 {
 #ifndef WIN32
   pthread_t *threads;
diff --git a/src/interfaces/libpq/test/libpq_testclient.c b/src/interfaces/libpq/test/libpq_testclient.c
index e552c09d36d..20730709ee7 100644
--- a/src/interfaces/libpq/test/libpq_testclient.c
+++ b/src/interfaces/libpq/test/libpq_testclient.c
@@ -13,7 +13,7 @@
 #include "libpq-fe.h"
 
 static void
-print_ssl_library()
+print_ssl_library(void)
 {
 	const char *lib = PQsslAttribute(NULL, "library");
 
-- 
2.34.1

>From ec5cded35e3d50902407895abe1016019142062e Mon Sep 17 00:00:00 2001
From: Bertrand Drouvot <[email protected]>
Date: Mon, 9 Mar 2026 09:31:22 +0000
Subject: [PATCH v1 2/2] Enable -Wstrict-prototypes and -Wold-style-definition
 by default

Those are available in all gcc and clang versions that support C11 and as C11
is required as of f5e0186f865c, then we can add them without capability test.

Having them enabled by default avoid having to chase these manually like
11171fe1fc8, cdf4b9aff2, 0e72b9d440, 7069dbcc31, f1283ed6cc, 7b66e2c086,
e95126cf04 and 9f7c527af3 have done.

Also, readline headers trigger a lot of warnings with -Wstrict-prototypes, so
we make use of the system_header pragma to hide the warnings.

Author: Bertrand Drouvot <[email protected]>
Discussion: https://postgr.es/m/13d51b20-a69c-4ac1-8546-ec4fc278064f%40eisentraut.org
Discussion: https://postgr.es/m/aTFctZwWSpl2/LG5%40ip-10-97-1-34.eu-west-3.compute.internal
---
 configure            | 8 ++++++++
 configure.ac         | 8 ++++++++
 meson.build          | 2 ++
 src/bin/psql/input.h | 9 +++++++++
 4 files changed, 27 insertions(+)
  24.8% src/bin/psql/

diff --git a/configure b/configure
index 42621ecd051..dda8217e808 100755
--- a/configure
+++ b/configure
@@ -16905,6 +16905,14 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
 fi
 
 
+# These flags are supported in all C11-capable GCC/Clang versions,
+# so no capability test is needed.  Added here to avoid affecting configure probes,
+# particularly PGAC_PRINTF_ARCHETYPE which uses -Werror and would fail to detect
+# gnu_printf if -Wstrict-prototypes is active.
+if test "$GCC" = yes -a "$ICC" = no; then
+  CFLAGS="$CFLAGS -Wstrict-prototypes -Wold-style-definition"
+fi
+
 # --------------------
 # Run tests below here
 # --------------------
diff --git a/configure.ac b/configure.ac
index 61ec895d23c..98d0698e4c8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2032,6 +2032,14 @@ related to locating shared libraries.  Check the file 'config.log'
 for the exact reason.]])],
 [AC_MSG_RESULT([cross-compiling])])
 
+# These flags are supported in all C11-capable GCC/Clang versions,
+# so no capability test is needed.  Added here to avoid affecting configure probes,
+# particularly PGAC_PRINTF_ARCHETYPE which uses -Werror and would fail to detect
+# gnu_printf if -Wstrict-prototypes is active.
+if test "$GCC" = yes -a "$ICC" = no; then
+  CFLAGS="$CFLAGS -Wstrict-prototypes -Wold-style-definition"
+fi
+
 # --------------------
 # Run tests below here
 # --------------------
diff --git a/meson.build b/meson.build
index 2df54409ca6..db3a3327cb5 100644
--- a/meson.build
+++ b/meson.build
@@ -2242,6 +2242,8 @@ if cc.has_argument('-Wmissing-variable-declarations')
   cflags_no_missing_var_decls += '-Wno-missing-variable-declarations'
 endif
 
+# These are C-only flags, supported in all C11-capable GCC/Clang versions.
+cflags_warn += cc.get_supported_arguments(['-Wstrict-prototypes', '-Wold-style-definition'])
 
 # The following tests want to suppress various unhelpful warnings by adding
 # -Wno-foo switches.  But gcc won't complain about unrecognized -Wno-foo
diff --git a/src/bin/psql/input.h b/src/bin/psql/input.h
index 09961c84101..2a47166347e 100644
--- a/src/bin/psql/input.h
+++ b/src/bin/psql/input.h
@@ -17,6 +17,15 @@
 #ifdef HAVE_LIBREADLINE
 #define USE_READLINE 1
 
+/*
+ * Readline headers trigger a lot of warnings with our preferred compiler flags
+ * (at least -Wstrict-prototypes is known to be problematic). The system_header
+ * pragma hides warnings from within the rest of this file, if supported.
+ */
+#ifdef HAVE_PRAGMA_GCC_SYSTEM_HEADER
+#pragma GCC system_header
+#endif
+
 #if defined(HAVE_READLINE_READLINE_H)
 #include <readline/readline.h>
 #if defined(HAVE_READLINE_HISTORY_H)
-- 
2.34.1

Reply via email to