Skip to content

Commit

Permalink
Documentation: Use builder.std rather than explicit compiler flags
Browse files Browse the repository at this point in the history
The `-std=c++11` flag only works with GNU-style compiler frontends
for MSVC this should be `/std:c++11`. Even better is to use the builder's
explicit C/C++ standard setter.
  • Loading branch information
dcoles committed Mar 3, 2024
1 parent 1fd8a5f commit 699a12a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ cxx-build = "1.0"
fn main() {
cxx_build::bridge("src/main.rs") // returns a cc::Build
.file("src/demo.cc")
.flag_if_supported("-std=c++11")
.std("c++11")
.compile("cxxbridge-demo");

println!("cargo:rerun-if-changed=src/main.rs");
Expand Down
2 changes: 1 addition & 1 deletion book/src/build/cargo.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ set up any additional source files and compiler flags as normal.
fn main() {
cxx_build::bridge("src/main.rs") // returns a cc::Build
.file("src/demo.cc")
.flag_if_supported("-std=c++11")
.std("c++11")
.compile("cxxbridge-demo");
println!("cargo:rerun-if-changed=src/main.rs");
Expand Down
4 changes: 2 additions & 2 deletions book/src/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ std::unique_ptr<BlobstoreClient> new_blobstore_client() {
}
```

Using `std::make_unique` would work too, as long as you pass `-std=c++14` to the
Using `std::make_unique` would work too, as long as you pass `std("c++14")` to the
C++ compiler as described later on.

The placement in *include/* and *src/* is not significant; you can place C++
Expand Down Expand Up @@ -222,7 +222,7 @@ integration.
# fn main() {
cxx_build::bridge("src/main.rs")
.file("src/blobstore.cc")
.flag_if_supported("-std=c++14")
.std("c++14")
.compile("cxx-demo");
# }
```
Expand Down

0 comments on commit 699a12a

Please sign in to comment.