rust-bindgen
rust-bindgen copied to clipboard
Generated bindings don't compile
bindgen 0.51.0
Input C/C++ Header
template <class, class Compare = int> class a { Compare b; };
namespace AZ {
template <class> struct c;
template <class e> struct EBusRouterPolicy {
using d = c<typename e::f>;
typedef a<d> Container;
};
} // namespace AZ
Bindgen Invocation
$ bindgen __bindgen.ii -- --std=c++14
Actual Results
/* automatically generated by rust-bindgen */
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct a<Compare> {
pub b: Compare,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<Compare>>,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct AZ_c {
pub _address: u8,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct AZ_EBusRouterPolicy {
pub _address: u8,
}
pub type AZ_EBusRouterPolicy_d = AZ_c;
pub type AZ_EBusRouterPolicy_Container = a<Compare>;
Compile above with rustc --crate-type lib
:
error[E0412]: cannot find type `Compare` in this scope
--> bindgen.rs:20:44
|
20 | pub type AZ_EBusRouterPolicy_Container = a<Compare>;
| ^^^^^^^ not found in this scope
Expected Results
Last line of bindings should probably be:
pub type AZ_EBusRouterPolicy_Container<Compare> = a<Compare>;
Thanks, nice test-case :)
I think this is bindgen getting confused about the dependent type...
I happened to confirm that the same error (Compare
"not found in scope") occurs as of v0.60.1.