2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * ***** END GPL LICENSE BLOCK *****
21 #ifndef __BLI_COMPILER_COMPAT_H__
22 #define __BLI_COMPILER_COMPAT_H__
24 /** \file BLI_compiler_compat.h
27 * Use to help with cross platform portability.
31 # define __func__ __FUNCTION__
32 # define alloca _alloca
35 #if defined(__cplusplus) && ((__cplusplus >= 201103L) || defined(_MSC_VER))
36 # define HAS_CPP11_FEATURES
39 #if (defined(__GNUC__) || defined(__clang__)) && defined(HAS_CPP11_FEATURES)
41 /* Some magic to be sure we don't have reference in the type. */
42 template<typename T> static inline T decltype_helper(T x) { return x; }
43 # define typeof(x) decltype(decltype_helper(x))
47 /* little macro so inline keyword works */
49 # define BLI_INLINE static __forceinline
51 # if (defined(__APPLE__) && defined(__ppc__))
52 /* static inline __attribute__ here breaks osx ppc gcc42 build */
53 # define BLI_INLINE static __attribute__((always_inline)) __attribute__((__unused__))
55 # define BLI_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__))
59 #endif /* __BLI_COMPILER_COMPAT_H__ */