Originally posted by Weasel
View Post
Originally posted by Weasel
View Post
bindgen task C/C++ header in one side and spits a rust compatible interface out the other. With how complex processing C/C++ headers are C and C++ compliers in lot of project use precompiled headers so need to run a convert here I don't see as problem.
Rust language lacks means at this stage to do
Code:
extern "C" { include "someheader.h" }
The section "Automatically generating the interface" yes bindings.rs option there is basically the precompiled header route so not having to process the C headers over and over converting them to rust slowing down build times.
Rust directly using C and C++ header files is most likely bad. Indirectly does exist without lots of developer work as long as you don't care about the interfaces being unsafe.
Originally posted by Weasel
View Post
Unsafe point issue I don't disagree with is a issue but you get something key wrong. bindgen the least work way of interfacing with C does not have means of generating a safe interfaces. If you mess around setting of bindgen options you can get it to spit out safe rust interfaces at times. Yes bindgen lacks the smarts to know hey I just processed X header file all the operations are safe so I should declare it safe yes lacks the means to declare the information in the C/C++ header file.
/** <div rustbindgen mustusetype></div> */
Like the command line for that is "--must-use-type <regex>"
You cannot create a wrapper.h and put all the commandline options you would pass into bindgen into it. This is a weakness of the current bindgen. Either you end up with a commandline from hell or having todo a lot of header file modifications this is more a implementation limitation of bindgen than a design defect.
Bindgen at this stage still does not contain enough options and processing intelligence to make safe interfaces as much as you would like.
Weasel my point of view is rusts interface generation from C, C++ and Object C need work. The bindgen bit need to be improved to the point where it can be giving the directives to spit out safe rust interfaces from C/C++/object C header files lot more often with less work.
Yes safe rust interfaces being able to be spat out with upstream support that could end in needing C/C++/object C header files need to contain a little extra information like C headers do so C++ use them without issue most of the time. Of course we need bindgen to be able to process that extra information and make safe interfaces.
Comment