-
Notifications
You must be signed in to change notification settings - Fork 796
Associated types not resolved to concrete type #1924
Copy link
Copy link
Open
Description
Input C/C++ Header
struct InnerType {
typedef int related_type;
};
template <typename ContainedType> class Container {
public:
typedef typename ContainedType::related_type contents;
contents contents_;
};
typedef Container<InnerType> Concrete;
struct LaterContainingType {
Concrete contents;
};Bindgen Invocation
let bindings = bindgen::Builder::default()
.header("wrapper.hpp")
.clang_args(&["-x", "c++", "-std=c++14"])
.layout_tests(false)
.whitelist_type("LaterContainingType")
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.generate()
.expect("Unable to generate bindings");Rust code
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
fn main() {
Concrete { contents_: 32 };
}Actual Results
$ cargo build
Compiling bindgen-test-case v0.1.0
error[E0308]: mismatched types
--> src/main.rs:8:27
|
8 | Concrete { contents_: 32 };
| ^^ expected array `[u8; 0]`, found integer
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
error: could not compile `bindgen-test-case`
Expected Results
I'd expect the type of contents_ to be a c_int.
Other notes
Perhaps this counts as the "traits templates" situation listed under the recorded C++ limitations but, as it doesn't involve any nasty SFINAE magic I am hoping this may be possible.
Thanks for bindgen, it's amazing! Apologies if this is a duplicate.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Give feedbackNo fields configured for issues without a type.