Fix MSVC build: disable [[msvc::forceinline]] on generic lambdas

libeigen/eigen!2171

Co-authored-by: Rasmus Munk Larsen <rmlarsen@gmail.com>
This commit is contained in:
Rasmus Munk Larsen
2026-02-21 00:13:58 -08:00
parent 95e8bc3267
commit 18791a81b9

View File

@@ -908,12 +908,11 @@
// EIGEN_LAMBDA_ALWAYS_INLINE forces inlining of lambda functions.
// On GCC/Clang, __attribute__((always_inline)) works on lambdas.
// On MSVC, __forceinline cannot be applied to lambdas, but the
// [[msvc::forceinline]] attribute (available since VS 2022 17.1) can.
// On MSVC, [[msvc::forceinline]] cannot be applied to generic lambdas
// (those with auto parameters), so we leave it empty and rely on the
// optimizer to inline small lambda bodies at /O2.
#if EIGEN_COMP_GNUC && !defined(SYCL_DEVICE_ONLY)
#define EIGEN_LAMBDA_ALWAYS_INLINE __attribute__((always_inline))
#elif EIGEN_COMP_MSVC >= 1931
#define EIGEN_LAMBDA_ALWAYS_INLINE [[msvc::forceinline]]
#else
#define EIGEN_LAMBDA_ALWAYS_INLINE
#endif