Skip to content

Commit ceca3d1

Browse files
committed
py/objtype: Move #if outside MP_DEFINE_CONST_OBJ_TYPE for MSVC.
MSVC doesn't support preprocessor conditionals inside macro arguments. Split the mp_type_type definition into two separate invocations based on MICROPY_PY_METACLASS_OPS to avoid placing #if/#endif inside the macro call. This fixes Windows port MSVC compilation errors C2121 and C2059. Signed-off-by: Andrew Leech <[email protected]>
1 parent 975d4cd commit ceca3d1

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

py/objtype.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,19 +1413,29 @@ static mp_obj_t type_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_
14131413
}
14141414
#endif // MICROPY_PY_METACLASS_OPS
14151415

1416+
#if MICROPY_PY_METACLASS_OPS
14161417
MP_DEFINE_CONST_OBJ_TYPE(
14171418
mp_type_type,
14181419
MP_QSTR_type,
14191420
MP_TYPE_FLAG_NONE,
14201421
make_new, type_make_new,
14211422
print, type_print,
14221423
call, type_call,
1423-
#if MICROPY_PY_METACLASS_OPS
14241424
unary_op, type_unary_op,
14251425
binary_op, type_binary_op,
1426-
#endif
14271426
attr, type_attr
14281427
);
1428+
#else
1429+
MP_DEFINE_CONST_OBJ_TYPE(
1430+
mp_type_type,
1431+
MP_QSTR_type,
1432+
MP_TYPE_FLAG_NONE,
1433+
make_new, type_make_new,
1434+
print, type_print,
1435+
call, type_call,
1436+
attr, type_attr
1437+
);
1438+
#endif
14291439

14301440
static mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict, const mp_obj_type_t *metaclass) {
14311441
// Verify input objects have expected type

0 commit comments

Comments
 (0)