Skip to content

Commit fa92f67

Browse files
committed
Merge pull request #76 from ax3l/fix-unusedVar
Close #69 Unused Var: Warning
2 parents d1f4d3e + 2dd5e3b commit fa92f67

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

include/pybind11/attr.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,24 +250,26 @@ template <int Nurse, int Patient> struct process_attribute<keep_alive<Nurse, Pat
250250
static void postcall(handle args, handle ret) { keep_alive_impl(Nurse, Patient, args, ret); }
251251
};
252252

253+
/// Ignore that a variable is unused in compiler warnings
254+
template<class T> void ignore_unused(const T&) { }
253255

254256
/// Recursively iterate over variadic template arguments
255257
template <typename... Args> struct process_attributes {
256258
static void init(const Args&... args, function_record *r) {
257259
int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::init(args, r), 0) ... };
258-
(void) unused; (void) r;
260+
ignore_unused(unused);
259261
}
260262
static void init(const Args&... args, type_record *r) {
261263
int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::init(args, r), 0) ... };
262-
(void) unused; (void) r;
264+
ignore_unused(unused);
263265
}
264266
static void precall(handle fn_args) {
265267
int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::precall(fn_args), 0) ... };
266-
(void) unused; (void) fn_args;
268+
ignore_unused(unused);
267269
}
268270
static void postcall(handle fn_args, handle fn_ret) {
269271
int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::postcall(fn_args, fn_ret), 0) ... };
270-
(void) unused; (void) fn_args; (void) fn_ret;
272+
ignore_unused(unused);
271273
}
272274
};
273275

0 commit comments

Comments
 (0)