[Bf-blender-cvs] [c16bd95] master: Enable GCC pedantic warnings with strict flags,

Campbell Barton noreply at git.blender.org
Sun Mar 30 06:05:01 CEST 2014


Commit: c16bd951cdff8d9dd4ba44e4634cb284c6f09342
Author: Campbell Barton
Date:   Sun Mar 30 15:02:24 2014 +1100
https://developer.blender.org/rBc16bd951cdff8d9dd4ba44e4634cb284c6f09342

Enable GCC pedantic warnings with strict flags,

also modify MIN/MAX macros to prevent shadowing.

===================================================================

M	intern/guardedalloc/intern/mallocn_guarded_impl.c
M	source/blender/blenlib/BLI_strict_flags.h
M	source/blender/blenlib/BLI_utildefines.h
M	source/blender/blenlib/intern/rand.c

===================================================================

diff --git a/intern/guardedalloc/intern/mallocn_guarded_impl.c b/intern/guardedalloc/intern/mallocn_guarded_impl.c
index 7a8545d..724e7f9 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 cb92f78..ce39078 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 bb1b3a3..46553cc 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 25a1a52..0afa4f8 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)




More information about the Bf-blender-cvs mailing list