From 12e6c14e699571ce5b86ffd2d88be49995e36cd2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 1 May 2026 11:07:44 -0400 Subject: [PATCH] PellesC: Add default -Ze flag to support compilation against Windows APIs The Pelles C compiler requires MS extensions to support `__declspec` and other constructs needed to use Windows APIs. Unfortunately the flag also disables standard definitions, so restore them. Issue: #21536 Co-authored-by: Serguei E. Leontiev --- .gitlab/ci/env_windows_pellesc13.01.ps1 | 4 ---- Modules/Platform/Windows-PellesC-C.cmake | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab/ci/env_windows_pellesc13.01.ps1 b/.gitlab/ci/env_windows_pellesc13.01.ps1 index 4a8b1cad43..84a38ac83d 100644 --- a/.gitlab/ci/env_windows_pellesc13.01.ps1 +++ b/.gitlab/ci/env_windows_pellesc13.01.ps1 @@ -1,6 +1,2 @@ . .gitlab/ci/ninja-env.ps1 . .gitlab/ci/pellesc-env.ps1 - -# FIXME(#21536): Avoid requiring the end user to enable -# Pelles C's Microsoft extensions to use Windows APIs. -$env:CFLAGS = "-Ze" diff --git a/Modules/Platform/Windows-PellesC-C.cmake b/Modules/Platform/Windows-PellesC-C.cmake index a22251c0b8..f5a3dad38c 100644 --- a/Modules/Platform/Windows-PellesC-C.cmake +++ b/Modules/Platform/Windows-PellesC-C.cmake @@ -7,6 +7,10 @@ __windows_compiler_pellesc(C) set(CMAKE_C_COMPILE_OBJECT " -Fo -c ") +# Enable Pelles C's Microsoft extensions to use Windows APIs. +# The flag also disables standard definitions, so add them. +string(APPEND CMAKE_C_FLAGS_INIT " -Ze -D__STDC__=1 -D__STDC_VERSION__=__POCC_STDC_VERSION__") + string(APPEND CMAKE_C_FLAGS_DEBUG_INIT " -Zi -Ob0") string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -Ot -Ob2 -DNDEBUG=1") string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO_INIT " -Zi -Ot -Ob1 -DNDEBUG=1")