BLI_utildefines: add UNUSED_VARS() macro

This commit is contained in:
Campbell Barton
2014-11-24 12:01:51 +01:00
parent ed350d9a52
commit 08fd38cf52
12 changed files with 68 additions and 21 deletions

View File

@@ -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;

View File

@@ -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 */

View File

@@ -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

View File

@@ -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
}

View File

@@ -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);
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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
}

View File

@@ -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);
}
/* *********************************************** */

View File

@@ -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 blender was built without python support\n");
return 0;
#endif /* WITH_PYTHON */
@@ -1191,7 +1191,7 @@ static int set_addons(int argc, const char **argv, void *data)
BPY_CTX_SETUP(BPY_string_exec(C, str));
free(str);
#else
(void)argv; (void)data; /* unused */
UNUSED_VARS(argv, data);
#endif /* WITH_PYTHON */
return 1;
}