Open jkorinth opened 1 month ago
That C++ code just compares two chunks of uninitialized memory fwiw.
My preference would be to fix this by generating std::array<>
rather than plain arrays in C++ mode. But special-casing the comparisons could work too.
Then you'd still have to support an approach for C? Like memcmp
the blocks? Technically, C++ classes with a single member are also repr[transparent]
, so you could also transfer the classes and implement Eq
on the classes. Then the generated code would work again. Not sure which is preferable?
We don't generate operator==
for C because C doesn't support operator overloading.
When generating C++ with
derive_eq=true
the implementation of the equality operator is wrong when using type aliases or#[repr(transparent)]
structs, e.g.:With
cbindgen.toml
:Generates this:
This fails a simple test in C++:
Output of
cargo tree
for reference: