Blender V4.3
BLI_compiler_compat.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5/* `#define typeof()` triggers a bug in some clang-format versions,
6 * disable format for entire file to keep results consistent. */
7/* clang-format off */
8
9#pragma once
10
11
18#if defined(_MSC_VER)
19# define alloca _alloca
20#endif
21
22#if (defined(__GNUC__) || defined(__clang__)) && defined(__cplusplus)
23extern "C++" {
25template<typename T> static inline T decltype_helper(T x)
26{
27 return x;
28}
29#define typeof(x) decltype(decltype_helper(x))
30}
31#endif
32
33/* little macro so inline keyword works */
34#if defined(_MSC_VER)
35# define BLI_INLINE static __forceinline
36#else
37# define BLI_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__))
38#endif
39
40#if defined(__GNUC__)
41# define BLI_NOINLINE __attribute__((noinline))
42#elif defined(_MSC_VER)
43# define BLI_NOINLINE __declspec(noinline)
44#else
45# define BLI_NOINLINE
46#endif