Giter Club home page Giter Club logo

Comments (9)

pvdrz avatar pvdrz commented on June 5, 2024 2

I propose closing this issue and maybe opening tracking issue listing all the other issues related to C++ features. What do you way?

from rust-bindgen.

fitzgen avatar fitzgen commented on June 5, 2024

Can bindgen handle SFINAE?

from rust-bindgen.

emilio avatar emilio commented on June 5, 2024

@fitzgen nope, for obvious reasons, sorry, forgot to mention it.

from rust-bindgen.

emilio avatar emilio commented on June 5, 2024

The template unions with template parameters thing should be doable once #61 lands.

from rust-bindgen.

gsingh93 avatar gsingh93 commented on June 5, 2024

I'm a bit surprised bindgen can't handle this:

$ cat test.h
template <typename T>
void foo(T a);
$ bindgen --version
bindgen 0.21.2
$ bindgen test.h -- -x c++
ERROR:bindgen::ir::item: Unhandled cursor kind CXCursorKind(30): Cursor(foo kind: FunctionTemplate, loc: test.h:2:6, usr: Some("c:@FT@>1#Tfoo#t0.0#v#"))
/* automatically generated by rust-bindgen */

Is this expected? It's not any fancy specialization, just a normal templated function.

from rust-bindgen.

fitzgen avatar fitzgen commented on June 5, 2024

@gsingh93

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.

from rust-bindgen.

fitzgen avatar fitzgen commented on June 5, 2024

Filed #492 for tracking explicit instantiations of template functions and generating bindings for them.

from rust-bindgen.

tamird avatar tamird commented on June 5, 2024

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 Unhandled cursor kind 30: Cursor(__test kind: FunctionTemplate bit tracked in #492, but also includes a bunch of Unhandled cursor kind 21: Cursor(__on_zero_shared kind: CXXMethod.

EDIT: also featured is Unhandled cursor kind 24: Cursor(shared_ptr<_Tp> kind: CXXConstructor.

from rust-bindgen.

pvdrz avatar pvdrz commented on June 5, 2024

superseded by #2343

from rust-bindgen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.