]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Always define `WIN32_LEAN_AND_MEAN` before <windows.h>
authorLIU Hao <lh_mouse@126.com>
Fri, 6 Jan 2023 15:18:15 +0000 (23:18 +0800)
committerJonathan Yong <10walls@gmail.com>
Sat, 7 Jan 2023 06:51:06 +0000 (06:51 +0000)
Recently, mingw-w64 has got updated <msxml.h> from Wine which is included
indirectly by <windows.h> if `WIN32_LEAN_AND_MEAN` is not defined. The
`IXMLDOMDocument` class has a member function named `abort()`, which gets
affected by our `abort()` macro in "system.h".

`WIN32_LEAN_AND_MEAN` should, nevertheless, always be defined. This
can exclude 'APIs such as Cryptography, DDE, RPC, Shell, and Windows
Sockets' [1], and speed up compilation of these files a bit.

[1] https://learn.microsoft.com/en-us/windows/win32/winprog/using-the-windows-headers

gcc/

PR middle-end/108300
* config/xtensa/xtensa-dynconfig.c: Define `WIN32_LEAN_AND_MEAN`
before <windows.h>.
* diagnostic-color.cc: Likewise.
* plugin.cc: Likewise.
* prefix.cc: Likewise.

gcc/ada/

PR middle-end/108300
* adaint.c: Define `WIN32_LEAN_AND_MEAN` before `#include
<windows.h>`.
* cio.c: Likewise.
* ctrl_c.c: Likewise.
* expect.c: Likewise.
* gsocket.h: Likewise.
* mingw32.h: Likewise.
* mkdir.c: Likewise.
* rtfinal.c: Likewise.
* rtinit.c: Likewise.
* seh_init.c: Likewise.
* sysdep.c: Likewise.
* terminals.c: Likewise.
* tracebak.c: Likewise.

gcc/jit/

PR middle-end/108300
* jit-w32.h: Define `WIN32_LEAN_AND_MEAN` before <windows.h>.

libatomic/

PR middle-end/108300
* config/mingw/lock.c: Define `WIN32_LEAN_AND_MEAN` before
<windows.h>.

libffi/

PR middle-end/108300
* src/aarch64/ffi.c: Define `WIN32_LEAN_AND_MEAN` before
<windows.h>.

libgcc/

PR middle-end/108300
* config/i386/enable-execute-stack-mingw32.c: Define
`WIN32_LEAN_AND_MEAN` before <windows.h>.
* libgcc2.c: Likewise.
* unwind-generic.h: Likewise.

libgfortran/

PR middle-end/108300
* intrinsics/sleep.c: Define `WIN32_LEAN_AND_MEAN` before
<windows.h>.

libgomp/

PR middle-end/108300
* config/mingw32/proc.c: Define `WIN32_LEAN_AND_MEAN` before
<windows.h>.

libiberty/

PR middle-end/108300
* make-temp-file.c: Define `WIN32_LEAN_AND_MEAN` before <windows.h>.
* pex-win32.c: Likewise.

libssp/

PR middle-end/108300
* ssp.c: Define `WIN32_LEAN_AND_MEAN` before <windows.h>.

libstdc++-v3/

PR middle-end/108300
* src/c++11/system_error.cc: Define `WIN32_LEAN_AND_MEAN` before
<windows.h>.
* src/c++11/thread.cc: Likewise.
* src/c++17/fs_ops.cc: Likewise.
* src/filesystem/ops.cc: Likewise.

libvtv/

PR middle-end/108300
* vtv_malloc.cc: Define `WIN32_LEAN_AND_MEAN` before <windows.h>.
* vtv_rts.cc: Likewise.
* vtv_utils.cc: Likewise.

36 files changed:
gcc/ada/adaint.c
gcc/ada/cio.c
gcc/ada/ctrl_c.c
gcc/ada/expect.c
gcc/ada/gsocket.h
gcc/ada/mingw32.h
gcc/ada/mkdir.c
gcc/ada/rtfinal.c
gcc/ada/rtinit.c
gcc/ada/seh_init.c
gcc/ada/sysdep.c
gcc/ada/terminals.c
gcc/ada/tracebak.c
gcc/config/xtensa/xtensa-dynconfig.c
gcc/diagnostic-color.cc
gcc/jit/jit-w32.h
gcc/plugin.cc
gcc/prefix.cc
libatomic/config/mingw/lock.c
libffi/src/aarch64/ffi.c
libgcc/config/i386/enable-execute-stack-mingw32.c
libgcc/libgcc2.c
libgcc/unwind-generic.h
libgfortran/intrinsics/sleep.c
libgo/misc/cgo/test/callback_c.c
libgomp/config/mingw32/proc.c
libiberty/make-temp-file.c
libiberty/pex-win32.c
libssp/ssp.c
libstdc++-v3/src/c++11/system_error.cc
libstdc++-v3/src/c++11/thread.cc
libstdc++-v3/src/c++17/fs_ops.cc
libstdc++-v3/src/filesystem/ops.cc
libvtv/vtv_malloc.cc
libvtv/vtv_rts.cc
libvtv/vtv_utils.cc

index d2604ca9b7746f41c867ed78f725681abf77e517..2cbad88e901aa7902f55fb6795abe5f2c373a44d 100644 (file)
@@ -227,6 +227,7 @@ UINT __gnat_current_ccs_encoding;
 
 #elif defined (_WIN32)
 
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <accctrl.h>
 #include <aclapi.h>
index fa731ca68dd9ecc6dabe399a9a3f70a51d8c9a8c..f004b4bf732d9df3ee6b08afb04b92cd5b4ab994 100644 (file)
@@ -67,6 +67,7 @@ extern "C" {
 #endif
 
 #ifdef RTX
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <Rtapi.h>
 #endif
index eeec3e64f7088a2470ad1dfa76d36a1ad9c58340..6b9fc85ac436ef12cbcadb4070fdbfa22b3e664f 100644 (file)
@@ -126,6 +126,7 @@ __gnat_uninstall_int_handler (void)
 
 #elif defined (__MINGW32__)
 
+#define WIN32_LEAN_AND_MEAN
 #include "mingw32.h"
 #include <windows.h>
 
index 48fb1076e91e11fcb2e1ebdc411f54dae8e406e6..87dc16825bec2be1e31959d0462fc8147cca6fe2 100644 (file)
@@ -71,6 +71,7 @@
 
 #ifdef _WIN32
 
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <process.h>
 #include <signal.h>
index 561f2ffb5662e53ee296a424362e6159bb09c028..804994e412677de4ed24b4e2dc283361cbc79205 100644 (file)
 
 #endif
 
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 
 #elif defined(VMS)
index d038211a1dc1d9833edfc4b3fe7846ebda5d9e7d..7f6622ad8a8ec1d35df1ef42bb69308f8356461c 100644 (file)
@@ -53,6 +53,7 @@
 #define _X86INTRIN_H_INCLUDED
 #define _EMMINTRIN_H_INCLUDED
 #endif
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 
 /* After including this file it is possible to use the character t as prefix
index d54d5ec71bbe698b2cef2b386b2a36113fd43822..1da321c551f5e1c0ba8320ef695276beec948f93 100644 (file)
@@ -43,6 +43,7 @@
 #endif
 
 #ifdef __MINGW32__
+#define WIN32_LEAN_AND_MEAN
 #include "mingw32.h"
 #include <windows.h>
 #ifdef MAXPATHLEN
index 543e3a29f074f69114d2166d69329f99fc98869e..bd73e2cbd2c7daf894013180dd71d73cf26e9651 100644 (file)
@@ -46,6 +46,7 @@ extern int __gnat_rt_init_count;
 /*  see initialize.c  */
 
 #if defined (__MINGW32__)
+#define WIN32_LEAN_AND_MEAN
 #include "mingw32.h"
 #include <windows.h>
 
index 1b351d33203beb3e537ae7525c4299e46b3b07fa..cd3471685067f929ca8aa41bd212169360eaf8f1 100644 (file)
@@ -70,6 +70,7 @@ int __gnat_rt_init_count = 0;
    and finalize properly the run-time. */
 
 #if defined (__MINGW32__)
+#define WIN32_LEAN_AND_MEAN
 #include "mingw32.h"
 #include <windows.h>
 
index 16a1f69d4292f5368a19ff70009b2eb8687c6c0b..85895b64b7c9ed9c08d1c97a5b24461eadacb411 100644 (file)
@@ -34,6 +34,7 @@
 
 #if defined (_WIN32) || (defined (__CYGWIN__) && defined (__SEH__))
 /* Include system headers, before system.h poisons malloc.  */
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <excpt.h>
 #endif
index 7bdfcbc047c623ee13c20385cc8494254b35ecaa..edf3b78bc5fe2135c22dd8d829c3f9aa4672cf46 100644 (file)
@@ -217,6 +217,7 @@ __gnat_ttyname (int filedes)
 #endif /* __CYGWIN__ */
 
 #if defined (__CYGWIN__) || defined (__MINGW32__)
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 
 int __gnat_is_windows_xp (void);
@@ -589,6 +590,7 @@ getc_immediate_common (FILE *stream,
    Ada programs.  */
 
 #ifdef WINNT
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 
 /* Provide functions to echo the values passed to WinMain (windows bindings
index 330128abf5d6af83e1ca6ae94e9b3227c6217d58..9e7c2de13dc6190da2db7e0c6d93e5f93fe15155 100644 (file)
@@ -151,6 +151,7 @@ __gnat_setup_winsize (void *desc ATTRIBUTE_UNUSED,
 #include <stdio.h>
 #include <stdlib.h>
 
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <winternl.h>
 #include <io.h>
index f4e739d5ecf729cd4ddb148118bac24d0059f0b2..c43aadeafa414c40f41345f84587f6fd193045f4 100644 (file)
@@ -93,6 +93,7 @@ extern void (*Unlock_Task) (void);
 
 #if defined (_WIN64) && defined (__SEH__)
 
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 
 #define IS_BAD_PTR(ptr) (IsBadCodePtr((FARPROC)ptr))
@@ -455,6 +456,7 @@ struct layout
 #elif defined (__i386__) || defined (__x86_64__)
 
 #if defined (__WIN32)
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #define IS_BAD_PTR(ptr) (IsBadCodePtr((FARPROC)ptr))
 #elif defined (__sun__)
index 0a611fd14b03e58446a541a72ba060c3f8458900..91d02ef720f1eb0fa65ec5ec8344a7f41af7a302 100644 (file)
@@ -29,6 +29,7 @@
 #if defined (HAVE_DLFCN_H)
 #include <dlfcn.h>
 #elif defined (_WIN32)
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #define ENABLE_PLUGIN
 #endif
index 532f31926cfee21291889e3aac614dfe4fee473d..5f2856d18e48a642ef8646baa41a130926d8f387 100644 (file)
@@ -22,6 +22,7 @@
 #include "diagnostic-url.h"
 
 #ifdef __MINGW32__
+#  define WIN32_LEAN_AND_MEAN
 #  include <windows.h>
 #endif
 
index 14b75764e63d044f7a33d09e8263a25f809b51b7..3c65ff1f53032591e4face6c2098e4f395f913ea 100644 (file)
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #include "config.h"
 
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 
 namespace gcc {
index 71ddbfe6c103dcb0c6f42cec3b3a523be68634a3..142f3fa4131fc0bf1f9bbc17e8b695e4660b74c5 100644 (file)
@@ -41,6 +41,7 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef NOMINMAX
 #define NOMINMAX
 #endif
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #endif
 
index f03d3575bf15119e1c73b367bca38422aa89b531..c2a37bde5eaa423627ffa3fe7ba1aea2b3399af9 100644 (file)
@@ -67,6 +67,7 @@ License along with GCC; see the file COPYING3.  If not see
 #include "system.h"
 #include "coretypes.h"
 #if defined(_WIN32) && defined(ENABLE_WIN32_REGISTRY)
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #endif
 #include "prefix.h"
index 6efa42cea7392fe07f263dff8da9fd8b897668f4..0dcf07031e66278f013ed74d959c9859eec2c0b4 100644 (file)
@@ -23,6 +23,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #define UWORD __shadow_UWORD
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #undef UWORD
 #include "libatomic_i.h"
index 5c85fcd0e9c9ba7dd77ebdc14b980c507776d451..b394c18fc56778ea63761ca4c8264ec970a81a52 100644 (file)
@@ -28,6 +28,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
 #include <ffi_common.h>
 #include "internal.h"
 #ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h> /* FlushInstructionCache */
 #endif
 #include <tramp.h>
index 461553581ad69ec9db1451d1fe2d445011931046..17e068cd8e48b988d12a6e5478963b2ac0ba4313 100644 (file)
@@ -22,6 +22,7 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 
 extern void __enable_execute_stack (void *);
index 3ebfcc83f35c17bc31ffa8e452d8f181912bda03..1f7f19b68a78f691d3d95caa3e42b9afa0f4ca91 100644 (file)
@@ -2273,6 +2273,7 @@ __clear_cache (void *beg __attribute__((__unused__)),
 /* Jump to a trampoline, loading the static chain address.  */
 
 #if defined(WINNT) && ! defined(__CYGWIN__)
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 int getpagesize (void);
 int mprotect (char *,int, int);
index bf721282d03849ba62198a1562f4709d4c008938..37fff9a81110cb1aaad02640e953feb4d3b3202d 100644 (file)
@@ -30,6 +30,7 @@
 
 #if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__)
 /* Only for _GCC_specific_handler.  */
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #endif
 
index cbaf590aca8c7781f3e02f18f41add6dddae50dd..b15ebfeb235de5a4812b0d195522926ed36981b2 100644 (file)
@@ -30,6 +30,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #endif
 
 #ifdef __MINGW32__
+# define WIN32_LEAN_AND_MEAN
 # include <windows.h>
 # undef sleep
 # define sleep(x) Sleep(1000*(x))
index 8921b7306c6b148f13611ecaca6da4b47dcbfb98..ee9397cb49647d453ba1b8f5de21f616f4bc79cb 100644 (file)
@@ -32,6 +32,7 @@ IntoC(void)
 }
 
 #ifdef WIN32
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 long long
 mysleep(int seconds) {
index 2e2011568c122171544a2b4c9637b7e4551eb08e..120c988832acbae6b8a04f2d18be61bb9efaa1cf 100644 (file)
@@ -30,6 +30,7 @@
    The following implementation uses win32 API routines.  */
 
 #include "libgomp.h"
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 
 /* Count the CPU's currently available to this process.  */
index 7bfc65ea61312756a111a9c7268e594dadf9e234..b54c87d24fe8aa5d36d2806648b62b15679735b5 100644 (file)
@@ -37,6 +37,7 @@ Boston, MA 02110-1301, USA.  */
 #include <sys/file.h>   /* May get R_OK, etc. on some systems.  */
 #endif
 #if defined(_WIN32) && !defined(__CYGWIN__)
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #endif
 #if HAVE_SYS_STAT_H
index 077812306545c670bd86713989b74f11342c3d4b..67a9f97fd9a2f854b399033140a1b311b6c83163 100644 (file)
@@ -20,6 +20,7 @@ Boston, MA 02110-1301, USA.  */
 
 #include "pex-common.h"
 
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 
 #ifdef HAVE_STDLIB_H
index 72b7a1d63ceadd3d00222c9cba4f5cc506040354..5ef8643cbb1053724025e72da153d5318b2395e4 100644 (file)
@@ -55,6 +55,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 /* Native win32 apps don't know about /dev/tty but can print directly
    to the console using  "CONOUT$"   */
 #if defined (_WIN32) && !defined (__CYGWIN__)
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <wincrypt.h>
 # define _PATH_TTY "CONOUT$"
index 5707e6b61d693265f01d7ee7c40d426a9e49c7e0..5c7642700615bb3c33cd38aaa4ca6c2f5f06763c 100644 (file)
@@ -33,6 +33,7 @@
 #undef __sso_string
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
+#define WIN32_LEAN_AND_MEAN
 #include <memory>
 #include <windows.h>
 #endif
index a803897909078966e891073a67143bf76c684cf6..4936f629c5a57b54b3fb0f55cc37dfedcf60ff4c 100644 (file)
@@ -35,6 +35,7 @@
 # ifdef _GLIBCXX_HAVE_SLEEP
 #  include <unistd.h>
 # elif defined(_GLIBCXX_USE_WIN32_SLEEP)
+#  define WIN32_LEAN_AND_MEAN
 #  include <windows.h>
 # elif defined _GLIBCXX_NO_SLEEP && defined _GLIBCXX_HAS_GTHREADS
 // We expect to be able to sleep for targets that support multiple threads:
@@ -63,7 +64,7 @@ static inline int get_nprocs()
 }
 # define _GLIBCXX_NPROCS get_nprocs()
 #elif defined(_GLIBCXX_USE_GET_NPROCS_WIN32)
-#define WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
 # include <windows.h>
 static inline int get_nprocs()
 {
@@ -79,6 +80,7 @@ static inline int get_nprocs()
 # include <unistd.h>
 # define _GLIBCXX_NPROCS sysconf(_SC_NPROC_ONLN)
 #elif defined(_WIN32)
+# define WIN32_LEAN_AND_MEAN
 # include <windows.h>
 static inline int get_nprocs()
 {
index ed5e9f7d5cf5606a2d017cf83d2355dc14e6a949..b540f848313c256af7ff5f3f91fbdd26b5091200 100644 (file)
@@ -54,6 +54,7 @@
 # include <utime.h> // utime
 #endif
 #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
+# define WIN32_LEAN_AND_MEAN
 # include <windows.h>
 #endif
 
index ab84eb845946a8749177956839978177ddc1d38b..c18cf0205070600e35d8b6c8645280eca6e1dd4e 100644 (file)
@@ -55,6 +55,7 @@
 # include <utime.h> // utime
 #endif
 #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
+# define WIN32_LEAN_AND_MEAN
 # include <windows.h>
 #endif
 
index 67c5de6d4e9ae30f62ba49b0f8d18ee772d3039d..31b334fa7a2e1df87cc891c782eb7d0870585046 100644 (file)
@@ -33,6 +33,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #if defined (__CYGWIN__) || defined (__MINGW32__)
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #else
 #include <sys/mman.h>
index ae9e6b6955a19105f9ea3b534b1403e9d2b1a0c6..6954b0417b6d245e7b0f4a375d164d560021b032 100644 (file)
 #include <stdio.h>
 #include <string.h>
 #if defined (__CYGWIN__) || defined (__MINGW32__)
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <winternl.h>
 #include <psapi.h>
index ed5c7711c4437e9d6f9533451a241168a4216d96..21c3466afb9525e4e05399efb6aa2050e2b206a3 100644 (file)
@@ -33,6 +33,7 @@
 #include <stdlib.h>
 #include <string.h>
 #if defined (__CYGWIN__) || defined (__MINGW32__)
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #else
 #include <execinfo.h>