MSVC 17.7 generates bad code in some lambda's, this has been reported upstream [1], and a workaround has been suggested by MS in the form of turning the inliner off. In consultation with the geo nodes people this was deemed a passable solution, there was only a single call to this method so performance wasn't a concern, so no special care had to be taken to single out just the problematic MSVC versions. If this bug pops up in other parts of our code where performance IS a concern a more delicate approach may be required. [1] https://developercommunity.visualstudio.com/t/10448291 Pull Request: https://projects.blender.org/blender/blender/pulls/112616
48 lines
1.1 KiB
C++
48 lines
1.1 KiB
C++
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/* clang-format off */
|
|
|
|
/* #define typeof() triggers a bug in some clang-format versions, disable format
|
|
* for entire file to keep results consistent. */
|
|
|
|
#pragma once
|
|
|
|
|
|
/** \file
|
|
* \ingroup bli
|
|
*
|
|
* Use to help with cross platform portability.
|
|
*/
|
|
|
|
#if defined(_MSC_VER)
|
|
# define alloca _alloca
|
|
#endif
|
|
|
|
#if (defined(__GNUC__) || defined(__clang__)) && defined(__cplusplus)
|
|
extern "C++" {
|
|
/** Some magic to be sure we don't have reference in the type. */
|
|
template<typename T> static inline T decltype_helper(T x)
|
|
{
|
|
return x;
|
|
}
|
|
#define typeof(x) decltype(decltype_helper(x))
|
|
}
|
|
#endif
|
|
|
|
/* little macro so inline keyword works */
|
|
#if defined(_MSC_VER)
|
|
# define BLI_INLINE static __forceinline
|
|
#else
|
|
# define BLI_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__))
|
|
#endif
|
|
|
|
#if defined(__GNUC__)
|
|
# define BLI_NOINLINE __attribute__((noinline))
|
|
#elif defined(_MSC_VER)
|
|
# define BLI_NOINLINE __declspec(noinline)
|
|
#else
|
|
# define BLI_NOINLINE
|
|
#endif
|