File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -144,6 +144,46 @@ manifest key][links]* in the Cargo reference.
144
144
145
145
[links]: https://doc.rust-lang.org/cargo/reference/build-scripts.html#the-links-manifest-key
146
146
147
+ ## Features
148
+
149
+ CXX provides features to enable additional or alternative APIs.
150
+
151
+ Features are enabled on the CXX crate for Cargo-based setups, and with compiler
152
+ options for non-Cargo setups.
153
+
154
+ The following features are available, see `[features]` section in [Cargo.toml](https://github.com/dtolnay/cxx/blob/master/Cargo.toml) for a full list:
155
+ <table>
156
+ <tr><th>feature</th><th>compiler option</th><th>description</th></tr>
157
+ <tr><td>c++14</td><td>-std=c++14 (gcc, clang), /std:c++14 (msvc)</td><td>Compile CXX with c++14</td></tr>
158
+ <tr><td>c++17</td><td>-std=c++17 (gcc, clang), /std:c++17 (msvc)</td><td>Compile CXX with c++17.
159
+ Enables string_view APIs for rust::str and rust::String</td></tr>
160
+ </table>
161
+
162
+ You will have to enable the feature on the CXX crate *as well as* add the
163
+ equivalent compiler option to your cargo build.
164
+
165
+ Example to e.g. enable C++17:
166
+ ```toml,hidelines
167
+ ## Cargo.toml
168
+ [dependencies]
169
+ cxx = { version = " 0.4" , features = [" c++17" ] }
170
+ ```
171
+
172
+ ```rust,noplayground
173
+ // build.rs
174
+
175
+ fn main() {
176
+ cxx_build::bridge(" src/main.rs" ) // returns a cc::Build
177
+ .file(" src/demo.cc" )
178
+ .flag_if_supported(" -std=c++17" )
179
+ .compile(" cxxbridge-demo" );
180
+
181
+ println!(" cargo:rerun-if-changed=src/main.rs" );
182
+ println!(" cargo:rerun-if-changed=src/demo.cc" );
183
+ println!(" cargo:rerun-if-changed=include/demo.h" );
184
+ }
185
+ ```
186
+
147
187
<br><br><br>
148
188
149
189
# Advanced features
You can’t perform that action at this time.
0 commit comments