diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-09-25 07:05:42 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-09-25 07:07:17 +0400 |
commit | 21462410eef2ad8c5b31aa5796a8319b54872c6c (patch) | |
tree | 54479050503a3745dfcbc13bcb1de84dfe01d466 /source/blender/blenlib/BLI_utildefines.h | |
parent | 6f2f80887b10f6a704a7394f0580e6ee39ea611d (diff) |
Move typecheck macros into own header
Diffstat (limited to 'source/blender/blenlib/BLI_utildefines.h')
-rw-r--r-- | source/blender/blenlib/BLI_utildefines.h | 49 |
1 files changed, 5 insertions, 44 deletions
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index 5724f0e6ad4..a829cc60106 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -54,8 +54,8 @@ #define _VA_NARGS_COUNT_MAX32(...) _VA_NARGS_EXPAND((__VA_ARGS__, \ 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, \ 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, \ - 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, \ - 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)) + 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, \ + 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)) #define _VA_NARGS_OVERLOAD_MACRO2(name, count) name##count #define _VA_NARGS_OVERLOAD_MACRO1(name, count) _VA_NARGS_OVERLOAD_MACRO2(name, count) #define _VA_NARGS_OVERLOAD_MACRO(name, count) _VA_NARGS_OVERLOAD_MACRO1(name, count) @@ -71,6 +71,9 @@ # define MAX2(x, y) (_TYPECHECK(x, y), (((x) > (y) ? (x) : (y)))) #endif +/* include after _VA_NARGS macro */ +#include "BLI_compiler_typecheck.h" + /* min/max */ #if defined(__GNUC__) || defined(__clang__) @@ -155,48 +158,6 @@ /* some math and copy defines */ -/* Causes warning: - * incompatible types when assigning to type 'Foo' from type 'Bar' - * ... the compiler optimizes away the temp var */ -#ifdef __GNUC__ -#define CHECK_TYPE(var, type) { \ - typeof(var) *__tmp; \ - __tmp = (type *)NULL; \ - (void)__tmp; \ -} (void)0 - -#define CHECK_TYPE_PAIR(var_a, var_b) { \ - typeof(var_a) *__tmp; \ - __tmp = (typeof(var_b) *)NULL; \ - (void)__tmp; \ -} (void)0 - -#define CHECK_TYPE_PAIR_INLINE(var_a, var_b) ((void)({ \ - typeof(var_a) *__tmp; \ - __tmp = (typeof(var_b) *)NULL; \ - (void)__tmp; \ -})) - -#else -# define CHECK_TYPE(var, type) -# define CHECK_TYPE_PAIR(var_a, var_b) -# define CHECK_TYPE_PAIR_INLINE(var_a, var_b) (void)0 -#endif - -/* can be used in simple macros */ -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) -# define CHECK_TYPE_INLINE(val, type) \ - (void)((void)(((type)0) != (0 ? (val) : ((type)0))), \ - _Generic((val), type: 0, const type: 0)) -#else -# define CHECK_TYPE_INLINE(val, type) \ - ((void)(((type)0) != (0 ? (val) : ((type)0)))) -#endif - -#define CHECK_TYPE_NONCONST(var) { \ - void *non_const = 0 ? (var) : NULL; \ - (void)non_const; \ -} (void)0 #define SWAP(type, a, b) { \ type sw_ap; \ |