Blender  V2.93
BLI_compiler_compat.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 /* clang-format off */
18 
19 /* #define typeof() triggers a bug in some clang-format versions, disable format
20  * for entire file to keep results consistent. */
21 
22 #pragma once
23 
24 
31 #if defined(_MSC_VER)
32 # define alloca _alloca
33 #endif
34 
35 #if (defined(__GNUC__) || defined(__clang__)) && defined(__cplusplus)
36 extern "C++" {
37 /* Some magic to be sure we don't have reference in the type. */
38 template<typename T> static inline T decltype_helper(T x)
39 {
40  return x;
41 }
42 #define typeof(x) decltype(decltype_helper(x))
43 }
44 #endif
45 
46 /* little macro so inline keyword works */
47 #if defined(_MSC_VER)
48 # define BLI_INLINE static __forceinline
49 #else
50 # define BLI_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__))
51 #endif
52 
53 #if defined(__GNUC__)
54 # define BLI_NOINLINE __attribute__((noinline))
55 #else
56 # define BLI_NOINLINE
57 #endif
#define T