Fix Windows build compatibility (MSVC cl.exe and clang-cl)#99
Open
lorisercole wants to merge 5 commits intowavefunction91:masterfrom
Open
Fix Windows build compatibility (MSVC cl.exe and clang-cl)#99lorisercole wants to merge 5 commits intowavefunction91:masterfrom
lorisercole wants to merge 5 commits intowavefunction91:masterfrom
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.
| return other.idx_st == idx_st and | ||
| other.idx_en == idx_en and | ||
| return other.idx_st == idx_st && | ||
| other.idx_en == idx_en && |
Comment on lines
354
to
+355
| bool operator==( iterator other ){ return idx_it == other.idx_it; } | ||
| bool operator!=( iterator other ){ return not (*this == other); } | ||
| bool operator!=( iterator other ){ return !(*this == other); } |
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.
C1061 'blocks nested too deeply'inwomersley.hppby splitting a 125-branch if-else dispatch into two halves and replacing another with a 3-line clampand,or,not) with&&,||,!across 11 headers for MSVC cl.exe compatibility (requires/permissive-otherwise)_USE_MATH_DEFINESforM_PI,/bigobjfor large test TUs-Wno-unused-but-set-variableand-Wno-suggest-overrideunder clang-cl-Wno-missing-bracesonly applying to consumers (wasINTERFACE), not to the compiled library sources whenINTEGRATORXX_HEADER_ONLY=OFF#include <numeric>in composite quadratures test