Add EIGEN_LAMBDA_ALWAYS_INLINE macro for MSVC lambda inlining

libeigen/eigen!2170

Closes #3033

Co-authored-by: Rasmus Munk Larsen <rmlarsen@gmail.com>
This commit is contained in:
Rasmus Munk Larsen
2026-02-20 21:28:47 -08:00
parent a87ecfb179
commit 95e8bc3267
2 changed files with 13 additions and 2 deletions

View File

@@ -906,6 +906,18 @@
#define EIGEN_ALWAYS_INLINE EIGEN_STRONG_INLINE
#endif
// 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.
#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
#if EIGEN_COMP_GNUC
#define EIGEN_DONT_INLINE __attribute__((noinline))
#elif EIGEN_COMP_MSVC