Fix Windows build compatibility (MSVC cl.exe and clang-cl)#99
Merged
wavefunction91 merged 15 commits intoJun 11, 2026
Conversation
MSVC has a hard limit of ~128 nesting levels for if-else chains. The Womersley quadrature traits had two functions exceeding this: - generate(): ~125-branch if-else dispatch. Split into two halves by extracting npts >= 2049 into a generate_large_npts_() helper, keeping each half under 64 branches. - next_algebraic_order(): ~125-branch if-else that simply returned the input clamped to [1, 125]. Replaced with a 3-line equivalent.
MSVC does not support C++ alternative operator tokens (and, or, not) without /permissive-. Replace with standard &&, ||, ! across all headers (11 files). Also add MSVC-specific flags to CMakeLists.txt: - _USE_MATH_DEFINES: needed for M_PI in MSVC CRT - /bigobj: test TUs exceed default COFF section limit
The flag was hardcoded as INTERFACE, which only propagates to consumers. When IntegratorXX builds as a compiled library (INTEGRATORXX_HEADER_ONLY=OFF), its own sources never received the suppression. Use INTEGRATORXX_TARGET_TYPE (PUBLIC or INTERFACE) so it matches the other target_compile_options calls. GCC hides this because it removed -Wmissing-braces from -Wall in GCC 4.8; Clang still enables it, causing thousands of warnings on clang-cl builds.
This was referenced May 7, 2026
There was a problem hiding this comment.
Pull request overview
This PR improves Windows build compatibility (MSVC cl.exe and clang-cl) by reducing MSVC parser limits in large dispatch code paths, avoiding C++ alternative operator tokens, and adjusting CMake compile options/definitions to apply correctly for both header-only and compiled-library builds.
Changes:
- Refactors the large Womersley
nptsdispatch and simplifiesnext_algebraic_orderto avoid MSVC C1061 nesting limits. - Replaces alternative operator tokens (
and,or,not) with&&,||,!across multiple headers for MSVC compatibility. - Updates CMake to apply warning suppressions correctly and adds MSVC-specific flags/definitions; adds a missing
<numeric>include to a test TU.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| CMakeLists.txt | Applies -Wno-missing-braces with the correct target scope; adds MSVC/clang-cl-specific flags/defs. |
| test/composite_quadratures.cxx | Adds missing <numeric> include for algorithms used in the test. |
| include/integratorxx/util/bound_transform.hpp | Replaces alternative tokens with standard logical operators. |
| include/integratorxx/quadratures/s2/womersley.hpp | Splits large if/else dispatch and clamps next_algebraic_order to avoid MSVC nesting-depth limits. |
| include/integratorxx/quadratures/radial/treutlerahlrichs.hpp | Replaces alternative tokens with &&. |
| include/integratorxx/quadratures/radial/muraknowles.hpp | Replaces alternative tokens with &&. |
| include/integratorxx/quadratures/radial/mhl.hpp | Replaces alternative tokens with &&. |
| include/integratorxx/quadratures/radial/becke.hpp | Replaces alternative tokens with &&. |
| include/integratorxx/quadratures/primitive/gausslobatto.hpp | Replaces not with ! in convergence check. |
| include/integratorxx/quadratures/primitive/gausslegendre.hpp | Replaces not with ! in convergence check. |
| include/integratorxx/quadrature.hpp | Replaces and with && in SFINAE constraints. |
| include/integratorxx/generators/spherical_factory.hpp | Replaces alternative tokens with && in equality operators. |
| include/integratorxx/composite_quadratures/pruned_spherical_quadrature.hpp | Replaces alternative tokens with && / ! in iterator comparisons. |
| include/integratorxx/batch/spherical_micro_batcher.hpp | Replaces alternative tokens with ` |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
wavefunction91
approved these changes
May 23, 2026
…ss-Legendre and Gauss-Lobatto
…ize_t→int for custom iterator::operator+(int)
Contributor
Author
|
Just adapted the build with MSVC -DCMAKE_CXX_FLAGS="/W3 /w14018 /w14055 /w14100 /w14102 /w14127 /w14146 /w14242 /w14244 /w14245 /w14254 /w14267 /w14302 /w14306 /w14308 /w14310 /w14389 /w14509 /w14510 /w14512 /w14532 /w14533 /w14610 /w14611 /w14700 /w14701 /w14703 /w14789 /w14995 /w14996" `
-DCMAKE_CXX_FLAGS_RELEASE="/O2 /DNDEBUG" `+ same for C flags |
wavefunction91
approved these changes
Jun 11, 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
Enable IntegratorXX to build and test cleanly with both MSVC
cl.exeandclang-clon Windows.Compiler compatibility fixes
womersley.hpp: split 125-branch if-else dispatch into two halves; replace another with a 3-line clampand,or,not) with&&,||,!across 11 headers (MSVC requires/permissive-otherwise)_USE_MATH_DEFINESforM_PIand/bigobjfor large test translation unitsMSVC warning fixes (all fixed at source)
::toupperreturnsint— use explicitunsigned charcast lambda instd::transform; explicitstatic_castforsize_t→point_typein Gauss-Legendre/Gauss-Lobatto and factorial→doubleinSphericalHarmonicsize_t→intnarrowing — useintin ref_value lambdas; castsize_ttoptrdiff_tinspherical_micro_batcher::at(); cast for customiterator::operator+(int)/EHscto IntegratorXX and FetchContent'd Catch2 targetsclang-cl warning fixes
-Wno-unused-but-set-variableand-Wno-suggest-override-Wno-missing-bracesscope: wasINTERFACE(consumers only), now matchesINTEGRATORXX_TARGET_TYPEso compiled library sources also receive itOther
#include <numeric>in composite quadratures testsize_tinquadrature_traitsto avoid downstream C4267 in GauXC