Ensure WIN32_LEAN_AND_MEAN is defined before including <windows.h>.
Multiple GCC components now define WIN32_LEAN_AND_MEAN before including <windows.h> to prevent macro conflicts and speed up compilation.
Several files across GCC’s libraries and testsuite now define WIN32_LEAN_AND_MEAN before including the <windows.h> header. This change addresses potential macro conflicts, such as with the abort() function, and can also slightly speed up compilation by excluding less commonly used Windows APIs.
In Details
This commit addresses PR108300 by consistently defining WIN32_LEAN_AND_MEAN before including <windows.h> in various parts of GCC, including libgfortran, libstdc++, and testsuite headers/sources. This is a followup to an earlier change (r13-5055-g902c755930326c) and is necessary to prevent macro redefinitions (e.g., abort()) caused by updated Wine headers indirectly included by <windows.h> and to optimize compilation times by excluding certain Win32 APIs.
- WIN32_LEAN_AND_MEAN
- A preprocessor macro that, when defined before including
<windows.h>, excludes certain less commonly used Windows APIs (like Cryptography, DDE, RPC, Shell, and Sockets) from the build. This reduces compile times and the size of the compiled code. - <windows.h>
- The primary header file for Windows API programming. It includes declarations for most of the Windows operating system functions and types.
- macro conflict
- Occurs when two or more preprocessor macros defined in different code sections have the same name, potentially leading to unexpected code behavior or compilation errors if not managed properly.