[Bf-blender-cvs] [08fd38c] master: BLI_utildefines: add UNUSED_VARS() macro

Campbell Barton noreply at git.blender.org
Mon Nov 24 12:03:08 CET 2014


Commit: 08fd38cf52e4d540e6a7d3ceeaedf4a4c3858f55
Author: Campbell Barton
Date:   Mon Nov 24 12:01:51 2014 +0100
Branches: master
https://developer.blender.org/rB08fd38cf52e4d540e6a7d3ceeaedf4a4c3858f55

BLI_utildefines: add UNUSED_VARS() macro

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

M	source/blender/blenkernel/intern/constraint.c
M	source/blender/blenkernel/intern/context.c
M	source/blender/blenlib/BLI_utildefines.h
M	source/blender/editors/space_script/script_edit.c
M	source/blender/imbuf/intern/indexer.c
M	source/blender/makesrna/intern/rna_define.c
M	source/blender/makesrna/intern/rna_rigidbody.c
M	source/blender/modifiers/intern/MOD_laplaciandeform.c
M	source/blender/modifiers/intern/MOD_laplaciansmooth.c
M	source/blender/modifiers/intern/MOD_skin.c
M	source/blender/nodes/composite/node_composite_tree.c
M	source/creator/creator.c

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

diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 574001e..10eb8b7 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -1971,7 +1971,7 @@ static void pycon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTa
 static void pycon_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
 {
 #ifndef WITH_PYTHON
-	(void)con; (void)cob; (void)targets; /* unused */
+	UNUSED_VARS(con, cob, targets);
 	return;
 #else
 	bPythonConstraint *data = con->data;
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index 4b0adaf..5ffc5c5 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -257,7 +257,7 @@ static void *ctx_wm_python_context_get(
 		}
 	}
 #else
-	(void)C, (void)member, (void)member_type;
+	UNUSED_VARS(C, member, member_type);
 #endif
 
 	/* don't allow UI context access from non-main threads */
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h
index 9a8877e..ef1312a 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -497,6 +497,56 @@ extern "C" {
 #  define UNUSED_FUNCTION(x) UNUSED_ ## x
 #endif
 
+/**
+ * UNUSED_VARS#(a, ...): quiet unused warnings
+ *
+ * <pre>
+ * for i in range(16):
+ *     args = [(chr(ord('a') + (c % 26)) + (chr(ord('0') + (c // 26)))) for c in range(i + 1)]
+ *     print("#define _VA_UNUSED_VARS_%d(%s) \\" % (i + 1, ", ".join(args)))
+ *     print("\t((void)(%s)%s)" %
+ *             (args[0], ((", _VA_UNUSED_VARS_" + str(i) + "(%s)") if i else "%s") % ", ".join((args[1:]))))
+ * </pre>
+ *
+ */
+
+#define _VA_UNUSED_VARS_1(a0) \
+	((void)(a0))
+#define _VA_UNUSED_VARS_2(a0, b0) \
+	((void)(a0), _VA_UNUSED_VARS_1(b0))
+#define _VA_UNUSED_VARS_3(a0, b0, c0) \
+	((void)(a0), _VA_UNUSED_VARS_2(b0, c0))
+#define _VA_UNUSED_VARS_4(a0, b0, c0, d0) \
+	((void)(a0), _VA_UNUSED_VARS_3(b0, c0, d0))
+#define _VA_UNUSED_VARS_5(a0, b0, c0, d0, e0) \
+	((void)(a0), _VA_UNUSED_VARS_4(b0, c0, d0, e0))
+#define _VA_UNUSED_VARS_6(a0, b0, c0, d0, e0, f0) \
+	((void)(a0), _VA_UNUSED_VARS_5(b0, c0, d0, e0, f0))
+#define _VA_UNUSED_VARS_7(a0, b0, c0, d0, e0, f0, g0) \
+	((void)(a0), _VA_UNUSED_VARS_6(b0, c0, d0, e0, f0, g0))
+#define _VA_UNUSED_VARS_8(a0, b0, c0, d0, e0, f0, g0, h0) \
+	((void)(a0), _VA_UNUSED_VARS_7(b0, c0, d0, e0, f0, g0, h0))
+#define _VA_UNUSED_VARS_9(a0, b0, c0, d0, e0, f0, g0, h0, i0) \
+	((void)(a0), _VA_UNUSED_VARS_8(b0, c0, d0, e0, f0, g0, h0, i0))
+#define _VA_UNUSED_VARS_10(a0, b0, c0, d0, e0, f0, g0, h0, i0, j0) \
+	((void)(a0), _VA_UNUSED_VARS_9(b0, c0, d0, e0, f0, g0, h0, i0, j0))
+#define _VA_UNUSED_VARS_11(a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0) \
+	((void)(a0), _VA_UNUSED_VARS_10(b0, c0, d0, e0, f0, g0, h0, i0, j0, k0))
+#define _VA_UNUSED_VARS_12(a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0) \
+	((void)(a0), _VA_UNUSED_VARS_11(b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0))
+#define _VA_UNUSED_VARS_13(a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0) \
+	((void)(a0), _VA_UNUSED_VARS_12(b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0))
+#define _VA_UNUSED_VARS_14(a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0) \
+	((void)(a0), _VA_UNUSED_VARS_13(b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0))
+#define _VA_UNUSED_VARS_15(a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0) \
+	((void)(a0), _VA_UNUSED_VARS_14(b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0))
+#define _VA_UNUSED_VARS_16(a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0) \
+	((void)(a0), _VA_UNUSED_VARS_15(b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0))
+
+
+/* reusable ELEM macro */
+#define UNUSED_VARS(...) VA_NARGS_CALL_OVERLOAD(_VA_UNUSED_VARS_, __VA_ARGS__)
+
 /*little macro so inline keyword works*/
 #if defined(_MSC_VER)
 #  define BLI_INLINE static __forceinline
diff --git a/source/blender/editors/space_script/script_edit.c b/source/blender/editors/space_script/script_edit.c
index 9077d0c..29a24cc 100644
--- a/source/blender/editors/space_script/script_edit.c
+++ b/source/blender/editors/space_script/script_edit.c
@@ -131,7 +131,7 @@ static int script_reload_exec(bContext *C, wmOperator *op)
 	WM_event_add_notifier(C, NC_WINDOW, NULL);
 	return OPERATOR_FINISHED;
 #else
-	(void)C, (void)op; /* unused */
+	UNUSED_VARS(C, op);
 	return OPERATOR_CANCELLED;
 #endif
 }
diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c
index 547a8df..e66be77 100644
--- a/source/blender/imbuf/intern/indexer.c
+++ b/source/blender/imbuf/intern/indexer.c
@@ -1170,7 +1170,7 @@ IndexBuildContext *IMB_anim_index_rebuild_context(struct anim *anim, IMB_Timecod
 
 	return context;
 
-	(void)tcs_in_use, (void)proxy_sizes_in_use, (void)quality;
+	UNUSED_VARS(tcs_in_use, proxy_sizes_in_use, quality);
 }
 
 void IMB_anim_index_rebuild(struct IndexBuildContext *context,
@@ -1189,7 +1189,7 @@ void IMB_anim_index_rebuild(struct IndexBuildContext *context,
 #endif
 	}
 
-	(void)stop, (void)do_update, (void)progress;
+	UNUSED_VARS(stop, do_update, progress);
 }
 
 void IMB_anim_index_rebuild_finish(IndexBuildContext *context, short stop)
@@ -1207,8 +1207,8 @@ void IMB_anim_index_rebuild_finish(IndexBuildContext *context, short stop)
 #endif
 	}
 
-	(void)stop;
-	(void)proxy_sizes;  /* static defined at top of the file */
+	/* static defined at top of the file */
+	UNUSED_VARS(stop, proxy_sizes);
 }
 
 
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 6668ce8..54c0800 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -639,7 +639,7 @@ void RNA_struct_free(BlenderRNA *brna, StructRNA *srna)
 	if (srna->flag & STRUCT_RUNTIME)
 		rna_freelinkN(&brna->structs, srna);
 #else
-	(void)brna, (void)srna;
+	UNUSED_VARS(brna, srna);
 #endif
 }
 
diff --git a/source/blender/makesrna/intern/rna_rigidbody.c b/source/blender/makesrna/intern/rna_rigidbody.c
index 86a8b16..58a12f6 100644
--- a/source/blender/makesrna/intern/rna_rigidbody.c
+++ b/source/blender/makesrna/intern/rna_rigidbody.c
@@ -644,8 +644,7 @@ static void rna_RigidBodyWorld_convex_sweep_test(
 		BKE_report(reports, RPT_ERROR, "Rigidbody world was not properly initialized, need to step the simulation first");
 	}
 #else
-	(void)rbw, (void)reports, (void)object, (void)ray_start, (void)ray_end;
-	(void)r_location, (void)r_hitpoint, (void)r_normal, (void)r_hit;
+	UNUSED_VARS(rbw, reports, object, ray_start, ray_end, r_location, r_hitpoint, r_normal, r_hit);
 #endif
 }
 
diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c
index ffadcda..a4f6d00 100644
--- a/source/blender/modifiers/intern/MOD_laplaciandeform.c
+++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c
@@ -767,7 +767,7 @@ static void LaplacianDeformModifier_do(
         LaplacianDeformModifierData *lmd, Object *ob, DerivedMesh *dm,
         float (*vertexCos)[3], int numVerts)
 {
-	(void)lmd, (void)ob, (void)dm, (void)vertexCos, (void)numVerts;
+	UNUSED_VARS(lmd, ob, dm, vertexCos, numVerts);
 }
 #endif  /* WITH_OPENNL */
 
diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
index 9ba0bfc..192e557 100644
--- a/source/blender/modifiers/intern/MOD_laplaciansmooth.c
+++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
@@ -613,7 +613,7 @@ static void laplaciansmoothModifier_do(
         LaplacianSmoothModifierData *smd, Object *ob, DerivedMesh *dm,
         float (*vertexCos)[3], int numVerts)
 {
-	(void)smd, (void)ob, (void)dm, (void)vertexCos, (void)numVerts;
+	UNUSED_VARS(smd, ob, dm, vertexCos, numVerts);
 }
 #endif  /* WITH_OPENNL */
 
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c
index d43fa11..bc8d86a 100644
--- a/source/blender/modifiers/intern/MOD_skin.c
+++ b/source/blender/modifiers/intern/MOD_skin.c
@@ -328,8 +328,7 @@ static bool build_hull(SkinOutput *so, Frame **frames, int totframe)
 
 	return true;
 #else
-	(void)so, (void)frames, (void)totframe;
-	(void)skin_frame_find_contained_faces;
+	UNUSED_VARS(so, frames, totframe, skin_frame_find_contained_faces);
 	return false;
 #endif
 }
diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c
index 6d5b85d..1883b08 100644
--- a/source/blender/nodes/composite/node_composite_tree.c
+++ b/source/blender/nodes/composite/node_composite_tree.c
@@ -236,11 +236,10 @@ void ntreeCompositExecTree(Scene *scene, bNodeTree *ntree, RenderData *rd, int r
 #ifdef WITH_COMPOSITOR
 	COM_execute(rd, scene, ntree, rendering, view_settings, display_settings);
 #else
-	(void)scene, (void)ntree, (void)rd, (void)rendering, (void)do_preview;
-	(void)view_settings, (void)display_settings;
+	UNUSED_VARS(scene, ntree, rd, rendering, view_settings, display_settings);
 #endif
 
-	(void)do_preview;
+	UNUSED_VARS(do_preview);
 }
 
 /* *********************************************** */
diff --git a/source/creator/creator.c b/source/creator/creator.c
index f7ad386..efef309 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -1128,7 +1128,7 @@ static int run_python_file(int argc, const char **argv, void *data)
 		return 0;
 	}
 #else
-	(void)argc; (void)argv; (void)data; /* unused */
+	UNUSED_VARS(argc, argv, data);
 	printf("This blender was built without python support\n");
 	return 0;
 #endif /* WITH_PYTHON */
@@ -1158,7 +1158,7 @@ static int run_python_text(int argc, const char **argv, void *data)
 		return 0;
 	}
 #else
-	(void)argc; (void)argv; (void)data; /* unused */
+	UNUSED_VARS(argc, argv, data);
 	printf("This blender was built without python support\n");
 	return 0;
 #endif /* WITH_PYTHON */
@@ -1173,7 +1173,7 @@ static int run_python_console(int UNUSED(argc), const char **argv, void *data)
 
 	return 0;
 #else
-	(void)argv; (void)data; /* unused */
+	UNUSED_VARS(argv, data);
 	printf("This blen

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list