GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc Performance Win

Ensure WIN32_LEAN_AND_MEAN is defined before including <windows.h>.

Libgo's cgo test now defines WIN32_LEAN_AND_MEAN before including <windows.h> to prevent macro conflicts.

The libgo/misc/cgo/test/callback_c.c file now consistently defines WIN32_LEAN_AND_MEAN before including <windows.h>. This change, related to PR middle-end/108300, prevents potential macro conflicts that arise from the inclusion of Wine’s updated headers, specifically concerning the abort() function.

In Details

This commit, part of the effort for PR middle-end/108300, ensures WIN32_LEAN_AND_MEAN is defined before <windows.h> in libgo/misc/cgo/test/callback_c.c. This addresses an indirect include issue where Wine's <msxml.h> (which defines IXMLDOMDocument) can cause conflicts with GCC's abort() macro when WIN32_LEAN_AND_MEAN is not defined. This follows similar changes in other GCC components.

For Context
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.
libgo
The Go runtime library used by GCC's Go compiler.
cgo
A tool that allows Go programs to call C code.
Filed Under: windowswindows.hpreprocessorlibgocgo