Skip to content

Fix Windows build compatibility (MSVC cl.exe and clang-cl)#99

Open
lorisercole wants to merge 5 commits intowavefunction91:masterfrom
lorisercole:fix/msvc-build
Open

Fix Windows build compatibility (MSVC cl.exe and clang-cl)#99
lorisercole wants to merge 5 commits intowavefunction91:masterfrom
lorisercole:fix/msvc-build

Conversation

@lorisercole
Copy link
Copy Markdown

  • Fix MSVC C1061 'blocks nested too deeply' in womersley.hpp by splitting a 125-branch if-else dispatch into two halves and replacing another with a 3-line clamp
  • Replace C++ alternative operator tokens (and, or, not) with &&, ||, ! across 11 headers for MSVC cl.exe compatibility (requires /permissive- otherwise)
  • Add MSVC-specific compile flags: _USE_MATH_DEFINES for M_PI, /bigobj for large test TUs
  • Suppress -Wno-unused-but-set-variable and -Wno-suggest-override under clang-cl
  • Fix -Wno-missing-braces only applying to consumers (was INTERFACE), not to the compiled library sources when INTEGRATORXX_HEADER_ONLY=OFF
  • Add missing #include <numeric> in composite quadratures test

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.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 npts dispatch and simplifies next_algebraic_order to 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); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants