Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-03-30 08:02:24 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-03-30 08:04:20 +0400
commitc16bd951cdff8d9dd4ba44e4634cb284c6f09342 (patch)
treede4f0af701a6516ac803e002038baeb7f61b13ec
parent0782187979b67a743fe612d7404fe5698a4a7f24 (diff)
Enable GCC pedantic warnings with strict flags,
also modify MIN/MAX macros to prevent shadowing.
-rw-r--r--intern/guardedalloc/intern/mallocn_guarded_impl.c2
-rw-r--r--source/blender/blenlib/BLI_strict_flags.h1
-rw-r--r--source/blender/blenlib/BLI_utildefines.h46
-rw-r--r--source/blender/blenlib/intern/rand.c2
4 files changed, 34 insertions, 17 deletions
diff --git a/intern/guardedalloc/intern/mallocn_guarded_impl.c b/intern/guardedalloc/intern/mallocn_guarded_impl.c
index 7a8545de524..724e7f95845 100644
--- a/intern/guardedalloc/intern/mallocn_guarded_impl.c
+++ b/intern/guardedalloc/intern/mallocn_guarded_impl.c
@@ -735,7 +735,7 @@ static void MEM_guarded_printmemlist_internal(int pydict)
membl->_count);
#else
print_error("%s len: " SIZET_FORMAT " %p\n",
- membl->name, SIZET_ARG(membl->len), membl + 1);
+ membl->name, SIZET_ARG(membl->len), (void *)(membl + 1));
#endif
#ifdef DEBUG_BACKTRACE
print_memhead_backtrace(membl);
diff --git a/source/blender/blenlib/BLI_strict_flags.h b/source/blender/blenlib/BLI_strict_flags.h
index cb92f7837ec..ce39078ea73 100644
--- a/source/blender/blenlib/BLI_strict_flags.h
+++ b/source/blender/blenlib/BLI_strict_flags.h
@@ -28,6 +28,7 @@
*/
#ifdef __GNUC__
+# pragma GCC diagnostic error "-Wpedantic"
# pragma GCC diagnostic error "-Wsign-conversion"
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 /* gcc4.6+ only */
# pragma GCC diagnostic error "-Wsign-compare"
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h
index bb1b3a368f0..46553ccc0fc 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -50,26 +50,42 @@
/* min/max */
#if defined(__GNUC__) || defined(__clang__)
-#define MIN2(x, y) ({ \
- typeof(x) x_ = (x); \
- typeof(y) y_ = (y); \
- ((x_) < (y_) ? (x_) : (y_)); })
+#define MIN2(a, b) __extension__ ({ \
+ typeof(a) a_ = (a); typeof(b) b_ = (b); \
+ ((a_) < (b_) ? (a_) : (b_)); })
-#define MAX2(x, y) ({ \
- typeof(x) x_ = (x); \
- typeof(y) y_ = (y); \
- ((x_) > (y_) ? (x_) : (y_)); })
+#define MAX2(a, b) __extension__ ({ \
+ typeof(a) a_ = (a); typeof(b) b_ = (b); \
+ ((a_) > (b_) ? (a_) : (b_)); })
+
+#define MIN3(a, b, c) __extension__ ({ \
+ typeof(a) a_ = (a); typeof(b) b_ = (b); typeof(c) c_ = (c); \
+ ((a_ < b_) ? ((a_ < c_) ? a_ : c_) : ((b_ < c_) ? b_ : c_)); })
+
+#define MAX3(a, b, c) __extension__ ({ \
+ typeof(a) a_ = (a); typeof(b) b_ = (b); typeof(c) c_ = (c); \
+ ((a_ > b_) ? ((a_ > c_) ? a_ : c_) : ((b_ > c_) ? b_ : c_)); })
+
+#define MIN4(a, b, c, d) __extension__ ({ \
+ typeof(a) a_ = (a); typeof(b) b_ = (b); typeof(c) c_ = (c); typeof(d) d_ = (d); \
+ ((a_ < b_) ? ((a_ < c_) ? ((a_ < d_) ? a_ : d_) : ((c_ < d_) ? c_ : d_)) : \
+ ((b_ < c_) ? ((b_ < d_) ? b_ : d_) : ((c_ < d_) ? c_ : d_))); })
+
+#define MAX4(a, b, c, d) __extension__ ({ \
+ typeof(a) a_ = (a); typeof(b) b_ = (b); typeof(c) c_ = (c); typeof(d) d_ = (d); \
+ ((a_ > b_) ? ((a_ > c_) ? ((a_ > d_) ? a_ : d_) : ((c_ > d_) ? c_ : d_)) : \
+ ((b_ > c_) ? ((b_ > d_) ? b_ : d_) : ((c_ > d_) ? c_ : d_))); })
#else
-#define MIN2(x, y) ((x) < (y) ? (x) : (y))
-#define MAX2(x, y) ((x) > (y) ? (x) : (y))
-#endif
+#define MIN2(a, b) ((a) < (b) ? (a) : (b))
+#define MAX2(a, b) ((a) > (b) ? (a) : (b))
-#define MIN3(x, y, z) (MIN2(MIN2((x), (y)), (z)))
-#define MIN4(x, y, z, a) (MIN2(MIN2((x), (y)), MIN2((z), (a))))
+#define MIN3(a, b, c) (MIN2(MIN2((a), (b)), (c)))
+#define MIN4(a, b, c, d) (MIN2(MIN2((a), (b)), MIN2((c), (d))))
-#define MAX3(x, y, z) (MAX2(MAX2((x), (y)), (z)))
-#define MAX4(x, y, z, a) (MAX2(MAX2((x), (y)), MAX2((z), (a))))
+#define MAX3(a, b, c) (MAX2(MAX2((a), (b)), (c)))
+#define MAX4(a, b, c, d) (MAX2(MAX2((a), (b)), MAX2((c), (d))))
+#endif
/* min/max that return a value of our choice */
#define MAX3_PAIR(cmp_a, cmp_b, cmp_c, ret_a, ret_b, ret_c) \
diff --git a/source/blender/blenlib/intern/rand.c b/source/blender/blenlib/intern/rand.c
index 25a1a528db4..0afa4f81dba 100644
--- a/source/blender/blenlib/intern/rand.c
+++ b/source/blender/blenlib/intern/rand.c
@@ -200,7 +200,7 @@ float BLI_frand(void)
void BLI_frand_unit_v3(float v[3])
{
- return BLI_rng_get_float_unit_v3(&theBLI_rng, v);
+ BLI_rng_get_float_unit_v3(&theBLI_rng, v);
}
float BLI_hash_frand(unsigned int seed)