cxx
cxx copied to clipboard
MSVC compiler warning on large negative enum value
I have an enum in a CXX bridge that's synchronized with its C++ source by also having it as an extern "C++" type. It has the attribute #[repr(i32)] and contains the variant FOO_BAR = -2147483648, (== i32::MIN; bits equivalent to 0x8000_0000_u32).
The compiler warning this generates may not be seen when the Cargo build otherwise succeeds.
The warning is this: https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4146?view=msvc-170.
The corresponding code from bridge_filename.rs.cc:
static_assert(static_cast<::std::int32_t>(FooBarEnum::FOO_BAR) == -2147483648, "disagrees with the value in #[cxx::bridge]");