llvm-project
03f86c6d - [Support][Driver][LLDB] Guard WIN32_LEAN_AND_MEAN definitions with #ifndef (#213045)

Commit
8 days ago
[Support][Driver][LLDB] Guard WIN32_LEAN_AND_MEAN definitions with #ifndef (#213045) Several Windows headers/TUs unconditionally `#define WIN32_LEAN_AND_MEAN`. When a build predefines the macro on the compiler command line (e.g. a toolchain that passes -DWIN32_LEAN_AND_MEAN, which clang treats as `#define WIN32_LEAN_AND_MEAN 1`), the differing token lists trigger -Wmacro-redefined, which becomes a hard error under -Werror. Guard the definitions with #ifndef, matching the adjacent NOMINMAX handling and the existing pattern in llvm/lib/Support/rpmalloc/rpmalloc.c. The macro is only a presence flag, so keeping an externally-provided definition is correct. Sites guarded: llvm/include/llvm/Support/Windows/WindowsSupport.h llvm/lib/WindowsDriver/MSVCPaths.cpp clang/lib/Driver/ToolChains/MSVC.cpp lldb/include/lldb/Host/windows/windows.h Meta ran into this internally building lldb on window after a sync with upstream from July commit, so adding guards would allow us to drop a workaround of ignoring the duplicate defines. Error: llvm\include\llvm/Support/Windows/WindowsSupport.h(29,9): error: 'WIN32_LEAN_AND_MEAN' macro redefined [-Werror,-Wmacro-redefined] 29 | #define WIN32_LEAN_AND_MEAN | ^ <command line>(10,9): note: previous definition is here 10 | #define WIN32_LEAN_AND_MEAN 1 | ^ 1 error generated.
Author
Parents
Loading