ctest
ctest copied to clipboard
Not clear how to test `const <type> <obj>;` fields
See this comment in git2-rs for details: https://github.com/alexcrichton/git2-rs/pull/315#issuecomment-393006101
Given:
// rust
#[repr(C)]
struct Foo {
pub bar: i32
}
and
// c
struct Foo {
const int32_t bar;
};
the Rust code does not expose any information about whether the C field is cv-qualified or not. That is, I don't think we can generate appropriate C tests for the struct field type just from only looking at the Rust code.
We could, conservatively, assume that C struct fields are always const qualified. I've implemented that approach in #41 .
This won't, however, work if the C struct fields are cv-qualified in general. Maybe we could add a way in the future to specify that certain fields from certain structs are cv-qualified, e.g., via a method to the test generator.
Maybe someday we could replace most methods with attributes:
// rust
#[repr(C)]
struct Foo {
#[cfg_attr(ctest, const_qualified)]
pub bar: i32
}
I think a better idea is to expose a method in the builder that allows you to tell ctest that a particular field of a struct is cv-qualified. That shouldn't be to hard to hack in, and I think we already have such a method for volatile.