@@ -1111,6 +1111,12 @@ impl Builder {
1111
1111
/// issues. The resulting file will be named something like `__bindgen.i` or
1112
1112
/// `__bindgen.ii`
1113
1113
pub fn dump_preprocessed_input ( & self ) -> io:: Result < ( ) > {
1114
+ fn check_is_cpp ( name_file : & str ) -> bool {
1115
+ name_file. ends_with ( ".hpp" ) || name_file. ends_with ( ".hxx" )
1116
+ || name_file. ends_with ( ".hh" )
1117
+ || name_file. ends_with ( ".h++" )
1118
+ }
1119
+
1114
1120
let clang = clang_sys:: support:: Clang :: find ( None , & [ ] ) . ok_or_else ( || {
1115
1121
io:: Error :: new ( io:: ErrorKind :: Other , "Cannot find clang executable" )
1116
1122
} ) ?;
@@ -1120,11 +1126,13 @@ impl Builder {
1120
1126
let mut wrapper_contents = String :: new ( ) ;
1121
1127
1122
1128
// Whether we are working with C or C++ inputs.
1123
- let mut is_cpp = false ;
1129
+ let mut is_cpp = self . options . clang_args . windows ( 2 ) . any ( |w| {
1130
+ w[ 0 ] == "-x=c++" || w[ 1 ] == "-x=c++" || w == & [ "-x" , "c++" ]
1131
+ } ) ;
1124
1132
1125
1133
// For each input header, add `#include "$header"`.
1126
1134
for header in & self . input_headers {
1127
- is_cpp |= header . ends_with ( ".hpp" ) ;
1135
+ is_cpp |= check_is_cpp ( header ) ;
1128
1136
1129
1137
wrapper_contents. push_str ( "#include \" " ) ;
1130
1138
wrapper_contents. push_str ( header) ;
@@ -1134,18 +1142,14 @@ impl Builder {
1134
1142
// For each input header content, add a prefix line of `#line 0 "$name"`
1135
1143
// followed by the contents.
1136
1144
for & ( ref name, ref contents) in & self . input_header_contents {
1137
- is_cpp |= name . ends_with ( ".hpp" ) ;
1145
+ is_cpp |= check_is_cpp ( name ) ;
1138
1146
1139
1147
wrapper_contents. push_str ( "#line 0 \" " ) ;
1140
1148
wrapper_contents. push_str ( name) ;
1141
1149
wrapper_contents. push_str ( "\" \n " ) ;
1142
1150
wrapper_contents. push_str ( contents) ;
1143
1151
}
1144
1152
1145
- is_cpp |= self . options . clang_args . windows ( 2 ) . any ( |w| {
1146
- w[ 0 ] == "-x=c++" || w[ 1 ] == "-x=c++" || w == & [ "-x" , "c++" ]
1147
- } ) ;
1148
-
1149
1153
let wrapper_path = PathBuf :: from ( if is_cpp {
1150
1154
"__bindgen.cpp"
1151
1155
} else {
0 commit comments