File tree Expand file tree Collapse file tree 6 files changed +15
-9
lines changed Expand file tree Collapse file tree 6 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,8 @@ be nowhere near as nice as using them in C++. You will have to manually call
7
7
constructors, destructors, overloaded operators, etc yourself.
8
8
9
9
When passing in header files, the file will automatically be treated as C++ if
10
- it ends in ` .hpp ` . If it doesn't, adding ` -x c++ ` clang args can be used to
11
- force C++ mode. You probably also want to use ` -std=c++14 ` or similar clang args
12
- as well.
10
+ it ends in ` .hpp ` . If it doesn't, adding the ` --cxx ` flag will force C++ mode.
11
+ You probably also want to use the clang arg ` -std=c++14 ` or similar as well.
13
12
14
13
You pretty much ** must** use [ allowlisting] ( ./allowlisting.md ) when working
15
14
with C++ to avoid pulling in all of the ` std::.* ` types, many of which ` bindgen `
@@ -71,8 +70,8 @@ cannot translate into Rust:
71
70
generate undefined behaviour. See
72
71
[ the tracking issue for exceptions] ( https://github.com/rust-lang/rust-bindgen/issues/1208 )
73
72
for more details.
74
-
73
+
75
74
* Return value optimization. C++ compilers will in certain circumstances optimize functions
76
75
returning a struct type value to instead take an extra hidden argument that refers
77
76
to the return value struct. ` bindgen ` cannot necessarily know about this optimization and
78
- thus at present ` bindgen ` -interfaces for these kinds of functions are invalid.
77
+ thus at present ` bindgen ` -interfaces for these kinds of functions are invalid.
Original file line number Diff line number Diff line change @@ -518,6 +518,9 @@ where
518
518
Arg :: new ( "sort-semantically" )
519
519
. long ( "sort-semantically" )
520
520
. help ( "Enables sorting of code generation in a predefined manner." ) ,
521
+ Arg :: new ( "cxx" )
522
+ . long ( "cxx" )
523
+ . help ( "Enables parsing C++ headers." ) ,
521
524
Arg :: new ( "V" )
522
525
. long ( "version" )
523
526
. help ( "Prints the version, and exits" ) ,
@@ -1007,5 +1010,9 @@ where
1007
1010
builder = builder. sort_semantically ( true ) ;
1008
1011
}
1009
1012
1013
+ if matches. is_present ( "cxx" ) {
1014
+ builder = builder. clang_args ( [ "-x" , "c++" ] ) ;
1015
+ }
1016
+
1010
1017
Ok ( ( builder, output, verbose) )
1011
1018
}
Original file line number Diff line number Diff line change 1
- // bindgen-flags: -- -x c++ --std=c++11
1
+ // bindgen-flags: --cxx -- --std=c++11
2
2
3
3
template <typename T>
4
4
struct Foo {
Original file line number Diff line number Diff line change 1
- // bindgen-flags: --rustified-enum ".*" --enable-cxx-namespaces -- -x c++ -std=c++11
1
+ // bindgen-flags: --rustified-enum ".*" --enable-cxx-namespaces --cxx -- -std=c++11
2
2
3
3
namespace foo {
4
4
enum class Bar : unsigned {
Original file line number Diff line number Diff line change 1
- // bindgen-flags: --rustified-enum '.*Rustified.*' --constified-enum-module '.*Module.*' -- -x c++ --std=c++14
1
+ // bindgen-flags: --rustified-enum '.*Rustified.*' --constified-enum-module '.*Module.*' --cxx -- --std=c++14
2
2
3
3
// Constified is default, so no flag for that.
4
4
Original file line number Diff line number Diff line change 1
- // bindgen-flags: --raw-line '#![cfg(feature = "nightly")]' --rust-target 1.33 -- -x c++ -std=c++11
1
+ // bindgen-flags: --raw-line '#![cfg(feature = "nightly")]' --rust-target 1.33 --cxx -- -std=c++11
2
2
3
3
#pragma pack(1)
4
4
You can’t perform that action at this time.
0 commit comments