Silence -Wmissing-variable-declarations in headerscheck.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 29 Aug 2025 14:46:13 +0000 (10:46 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 29 Aug 2025 14:46:13 +0000 (10:46 -0400)
Newer gcc versions will emit warnings about missing extern
declarations if certain header files are compiled by themselves.
Add the "extern" declarations needed to quiet that.

Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://postgr.es/m/1127775.1754417387@sss.pgh.pa.us

src/interfaces/ecpg/test/expected/preproc-strings.c
src/interfaces/ecpg/test/preproc/strings.h
src/tools/gen_keywordlist.pl

index a26817968de7990e0f85592c55e951fb50b20cd6..06a86a2bfae4be099a30cf40cab5b418affa67ac 100644 (file)
 #line 3 "strings.pgc"
 /* exec sql begin declare section */
 #line 1 "strings.h"
+/* redundant declaration to silence -Wmissing-variable-declarations */
+  
+          
+          
+          
+          
+          
+          
+          
+
       
           
           
 
 #line 5 "strings.pgc"
 
-#line 1 "strings.h"
+#line 2 "strings.h"
+ extern char * s1 , * s2 , * s3 , * s4 , * s5 , * s6 , * s7 , * s8 ;
+#line 11 "strings.h"
  char * s1 , * s2 , * s3 , * s4 , * s5 , * s6 , * s7 , * s8 ;
 /* exec sql end declare section */
 #line 5 "strings.pgc"
index edb5be5339e6dc236ebeb837bfb08371f5f1b12b..8932b4ea9ed11b526e88614092efa2e9807065ea 100644 (file)
@@ -1,3 +1,13 @@
+/* redundant declaration to silence -Wmissing-variable-declarations */
+extern char *s1,
+          *s2,
+          *s3,
+          *s4,
+          *s5,
+          *s6,
+          *s7,
+          *s8;
+
 char      *s1,
           *s2,
           *s3,
index 6ec83ff33f9a9378e39d4ff736d7c7106bb040ca..bcb0d8027a04dd8a466f97b4a51328c63809ed0d 100644 (file)
@@ -169,7 +169,16 @@ printf $kwdef qq|static %s\n|, $f;
 
 # Emit the struct that wraps all this lookup info into one variable.
 
-printf $kwdef "static " if !$extern;
+if ($extern)
+{
+   # redundant declaration to silence -Wmissing-variable-declarations
+   printf $kwdef "extern PGDLLIMPORT const ScanKeywordList %s;\n\n",
+     $varname;
+}
+else
+{
+   printf $kwdef "static ";
+}
 printf $kwdef "const ScanKeywordList %s = {\n", $varname;
 printf $kwdef qq|\t%s_kw_string,\n|, $varname;
 printf $kwdef qq|\t%s_kw_offsets,\n|, $varname;