-
Notifications
You must be signed in to change notification settings - Fork 700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C++ features we can't handle right now. #41
Comments
Can bindgen handle SFINAE? |
@fitzgen nope, for obvious reasons, sorry, forgot to mention it. |
The template unions with template parameters thing should be doable once #61 lands. |
I'm a bit surprised bindgen can't handle this:
Is this expected? It's not any fancy specialization, just a normal templated function. |
We can't invoke the C++ compiler to generate new instantiations of templates, so I don't think we even try to keep track of them currently. Perhaps we could track explicit instantiations of template functions (14.7.2 in the standard) and make bindings to those. For example, if given template<class T> void foo(T t) { /∗ ... ∗/ }
template void foo(char);
template void foo(int); We could generate something like: extern "C" {
#[link_name = "..."]
pub fn foo_char(char);
#[link_name = "..."]
pub fn foo_int(int);
} But either way, we can't create new template instantiations since we aren't a C++ compiler and aren't creatign new object files from C++ code, so without those explicit instantiations to help us know what already exists, I don't think we can do much else. |
Filed #492 for tracking explicit instantiations of template functions and generating bindings for them. |
Just hit this while trying to work on #492. Here's the output, in case anyone finds it helpful: https://gist.github.com/anonymous/d20daf345e3b7512061c719e15684bb9. Note that it includes the EDIT: also featured is |
I propose closing this issue and maybe opening tracking issue listing all the other issues related to C++ features. What do you way? |
superseded by #2343 |
This is a list of things we can't handle correctly in bindgen, and we're not expected to be able to in a while.
Partial template specialization
We can't get the specialized types from a construct like this via libclang, rather unfortunately. We do hackily search through the ast to get the non-specialized ones though.
In the above example the ast for
Bar
is the following:And type template parameter related functions in bindgen don't give us any information.
Template unions with template parameters inside.
We can't handle this because the size of the union depends on
size_of::<T>
, and that's notconst fn
(and we can't useconst fn
in stable anyway). We can try to compute it and be correct ifT
is not the largest type in the union.The text was updated successfully, but these errors were encountered: