Fix compiler warnings around _CRT_glob
authorPeter Eisentraut <[email protected]>
Wed, 1 Oct 2025 15:13:52 +0000 (17:13 +0200)
committerPeter Eisentraut <[email protected]>
Wed, 1 Oct 2025 15:13:52 +0000 (17:13 +0200)
Newer compilers warned about

    extern int _CRT_glob = 0;

which is indeed a mysterious C construction, as it combines "extern"
and an initialization.  It turns out that according to the C standard,
the "extern" is ignored here, so we can remove it to resolve the
warnings.  But then we also need to add a real extern
declaration (without initializer) to satisfy
-Wmissing-variable-declarations.

(Note that this code is only active on MinGW.)

Discussion: https://www.postgresql.org/message-id/1053279b-da01-4eb4-b7a3-da6b5d8f73d1%40eisentraut.org

src/common/exec.c

index 8b690a10185014140a6fce11f60130a03e3c9329..cca89f040747fa732de491234e1a29f9e31f8bcd 100644 (file)
@@ -46,7 +46,8 @@
 
 /* Inhibit mingw CRT's auto-globbing of command line arguments */
 #if defined(WIN32) && !defined(_MSC_VER)
-extern int _CRT_glob = 0;      /* 0 turns off globbing; 1 turns it on */
+extern int _CRT_glob;
+int            _CRT_glob = 0;      /* 0 turns off globbing; 1 turns it on */
 #endif
 
 /*