Define _WIN32 for gfortran when building vendored pFUnit on Windows - #167
Merged
Conversation
gfortran's -cpp preprocessing doesn't predefine _WIN32 the way a C/C++ compiler does, so FUnit.F90's #ifndef _WIN32 guard around `use pf_RegexFilter` picks the wrong branch on Windows even though CMake's own WIN32 check already excluded that module from the build. See #163.
This was referenced Sep 2, 2026
This was referenced Sep 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
scripts/develop.sh's GFE/pFUnit build fails on Windows at thefunit-maintarget:FUnit.F90guardsuse pf_RegexFilteron#ifndef _WIN32, but gfortran's-cpppreprocessing does not predefine_WIN32the way a C/C++ compiler does, so the guard silently takes the wrong branch and tries to use a module that pFUnit's own CMakeLists correctly excluded from the Windows build via CMake'sWIN32variable.#163
Changes
scripts/develop.sh: on Windows (detected viauname -smatchingMINGW*/MSYS*/CYGWIN*), pass-DCMAKE_Fortran_FLAGS=-D_WIN32when configuring the vendored GFE build, soFUnit.F90's existing#ifndef _WIN32guard sees the same platform signal CMake's ownWIN32check does. No change on Linux/macOS.This depends on nothing else, but #165 currently has a doc change that assumes this fix is in place (it drops the "Windows: currently fails" caveat from CONTRIBUTING.md) — that PR should merge at the same time as or after this one, not before, or CONTRIBUTING.md would briefly overclaim Windows support.
Testing
Reproduced the exact failure from #163, then verified the fix end-to-end from a clean configure:
Went further and built CEA itself against that install (
core-cpreset,CEA_BUILD_TESTING=ON) and ran the pFUnit suite on Windows for what's believed to be the first time:ctest -R cea_core_test -V— 124/124 tests passed.Compatibility / Numerical behavior
Drafted with Claude's assistance
_WIN32-not-predefined-by-gfortran diagnosis was confirmed directly: preprocessing a minimal#ifndef _WIN32test program with and without an explicit-D_WIN32, using the same gfortran binary from thecea-devconda env, showed the guard picks the wrong branch without the flag.cea_core_testpFUnit suite (124 tests) was built and run against that install on Windows, all passing.