From 699a12a67a684bcf98af4c9646cb9d65e5373c21 Mon Sep 17 00:00:00 2001 From: David Coles Date: Sat, 2 Mar 2024 16:03:35 -0800 Subject: [PATCH] Documentation: Use `builder.std` rather than explicit compiler flags 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. --- README.md | 2 +- book/src/build/cargo.md | 2 +- book/src/tutorial.md | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 883cfe533..694bf2fad 100644 --- a/README.md +++ b/README.md @@ -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"); diff --git a/book/src/build/cargo.md b/book/src/build/cargo.md index 3d82baed1..6e9af8027 100644 --- a/book/src/build/cargo.md +++ b/book/src/build/cargo.md @@ -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"); diff --git a/book/src/tutorial.md b/book/src/tutorial.md index 9c1b5c2cd..cafa24d3c 100644 --- a/book/src/tutorial.md +++ b/book/src/tutorial.md @@ -159,7 +159,7 @@ std::unique_ptr 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++ @@ -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"); # } ```