Skip to content

Commit 43a84e3

Browse files
authored
Add explicit casts to avoid compiler warnings (#1294)
1 parent 52012da commit 43a84e3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

include/nanobind/nb_func.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ NB_INLINE PyObject *func_create(Func &&func, Return (*)(Args...),
195195
// Pre-initialize argument flags with 'convert'. The 'accepts_none' flag
196196
// for std::optional<> args is applied after func_extra_apply (see below).
197197
if constexpr (has_arg_defaults) {
198-
((void)(Is < is_method_det ||
198+
((void)(Is < (size_t)is_method_det ||
199199
(f.args[Is - is_method_det] = { nullptr, nullptr, nullptr, nullptr,
200200
(uint8_t) cast_flags::convert }, true)), ...);
201201
} else if constexpr (nargs_provided > 0) {
@@ -328,7 +328,7 @@ NB_INLINE PyObject *func_create(Func &&func, Return (*)(Args...),
328328
// Apply implicit accepts_none for std::optional<> typed arguments
329329
// after func_extra_apply, so that explicit nb::arg().noconvert() works.
330330
if constexpr (has_arg_defaults) {
331-
((void)(Is >= is_method_det && has_arg_defaults_v<Args> &&
331+
((void)(Is >= (size_t)is_method_det && has_arg_defaults_v<Args> &&
332332
(f.args[Is - is_method_det].flag |=
333333
(uint8_t) cast_flags::accepts_none, true)), ...);
334334
}

src/nb_ndarray.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ static PyObject *nb_ndarray_dlpack(PyObject *self, PyObject *const *args,
271271

272272
ndarray_handle *th = ((nb_ndarray *) self)->th;
273273
PyObject *capsule;
274-
if (max_major_version >= dlpack::major_version)
274+
if (max_major_version >= (long)dlpack::major_version)
275275
capsule = th->make_capsule_versioned();
276276
else
277277
capsule = th->make_capsule_unversioned();

0 commit comments

Comments
 (0)