From b5ee3d374ba275b6d939a7d270f9e623f4212dd3 Mon Sep 17 00:00:00 2001 From: kbkpbot Date: Fri, 12 Sep 2025 13:41:50 +0800 Subject: [PATCH] fix -cstrict --- vlib/v/checker/tests/enum_field_overflow.out | 6 +++--- vlib/v/checker/tests/enum_field_value_overflow.out | 8 ++++---- vlib/v/gen/c/cgen.v | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/vlib/v/checker/tests/enum_field_overflow.out b/vlib/v/checker/tests/enum_field_overflow.out index c51d6580c4..7bca995ae8 100644 --- a/vlib/v/checker/tests/enum_field_overflow.out +++ b/vlib/v/checker/tests/enum_field_overflow.out @@ -1,11 +1,11 @@ -vlib/v/checker/tests/enum_field_overflow.vv:3:10: error: enum value `2147483647` overflows the enum type `int`, values of which have to be in [-2147483648, 2147483647] - 1 | enum Color { +vlib/v/checker/tests/enum_field_overflow.vv:3:10: error: enum value `2147483647` overflows the enum type `i32`, values of which have to be in [-2147483648, 2147483647] + 1 | enum Color as i32 { 2 | red 3 | green = 2147483647 | ~~~~~~~~~~ 4 | blue 5 | } -vlib/v/checker/tests/enum_field_overflow.vv:4:2: error: enum value overflows type `int`, which has a maximum value of 2147483647 +vlib/v/checker/tests/enum_field_overflow.vv:4:2: error: enum value overflows type `i32`, which has a maximum value of 2147483647 2 | red 3 | green = 2147483647 4 | blue diff --git a/vlib/v/checker/tests/enum_field_value_overflow.out b/vlib/v/checker/tests/enum_field_value_overflow.out index 55c8cc2bb8..30c8e9664b 100644 --- a/vlib/v/checker/tests/enum_field_value_overflow.out +++ b/vlib/v/checker/tests/enum_field_value_overflow.out @@ -1,5 +1,5 @@ -vlib/v/checker/tests/enum_field_value_overflow.vv:3:10: error: enum value `2147483648` overflows the enum type `int`, values of which have to be in [-2147483648, 2147483647] - 1 | enum Color { +vlib/v/checker/tests/enum_field_value_overflow.vv:3:10: error: enum value `2147483648` overflows the enum type `i32`, values of which have to be in [-2147483648, 2147483647] + 1 | enum Color as i32 { 2 | red 3 | green = 2147483648 | ~~~~~~~~~~ @@ -40,8 +40,8 @@ vlib/v/checker/tests/enum_field_value_overflow.vv:21:10: error: enum value `3276 | ~~~~~ 22 | blue 23 | } -vlib/v/checker/tests/enum_field_value_overflow.vv:27:10: error: enum value `2147483648` overflows the enum type `int`, values of which have to be in [-2147483648, 2147483647] - 25 | enum ColorI32 { +vlib/v/checker/tests/enum_field_value_overflow.vv:27:10: error: enum value `2147483648` overflows the enum type `i32`, values of which have to be in [-2147483648, 2147483647] + 25 | enum ColorI32 as i32 { 26 | red 27 | green = 2147483648 | ~~~~~~~~~~ diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 6c5a5f8eb5..b615c06ca5 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -8316,9 +8316,9 @@ return ${cast_shared_struct_str}; } iin_idx := already_generated_mwrappers[interface_index_name] - iinidx_minimum_base if g.pref.build_mode != .build_module { - sb.writeln('${g.static_modifier}const int ${interface_index_name} = ${iin_idx};') + sb.writeln('${g.static_modifier}const u32 ${interface_index_name} = ${iin_idx};') } else { - sb.writeln('extern const int ${interface_index_name};') + sb.writeln('extern const u32 ${interface_index_name};') } } for vtyp, variants in inter_info.conversions {