From ec7b7e37ce97d25adc209befb2c12cf16eb06ef1 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 28 Jun 2016 13:00:14 +0300 Subject: Port to MSVC --- build2/b.cxx | 4 ---- build2/bin/target.cxx | 2 +- build2/cli/target.cxx | 4 ++-- build2/cxx/target.cxx | 14 +++++++------- build2/cxx/utility.cxx | 6 +++--- build2/diagnostics | 27 +++++++++++---------------- build2/scope.cxx | 4 +++- build2/target.cxx | 7 ++++--- build2/variable | 5 ++++- build2/variable.cxx | 15 +++++++-------- build2/variable.txx | 4 ++-- 11 files changed, 44 insertions(+), 48 deletions(-) (limited to 'build2') diff --git a/build2/b.cxx b/build2/b.cxx index 713b227..3be9f95 100644 --- a/build2/b.cxx +++ b/build2/b.cxx @@ -5,10 +5,6 @@ #include // tzset() #include // strerror() -#include // getenv() -#include // getuid() -#include // uid_t - #include #include // strcmp(), strchr() #include diff --git a/build2/bin/target.cxx b/build2/bin/target.cxx index b0ce6d5..f141d97 100644 --- a/build2/bin/target.cxx +++ b/build2/bin/target.cxx @@ -10,7 +10,7 @@ namespace build2 { namespace bin { - constexpr const char ext_var[] = "extension"; + extern const char ext_var[] = "extension"; // VC 19 rejects constexpr. static target* obja_factory (const target_type&, diff --git a/build2/cli/target.cxx b/build2/cli/target.cxx index 52ddd17..e3d1526 100644 --- a/build2/cli/target.cxx +++ b/build2/cli/target.cxx @@ -15,8 +15,8 @@ namespace build2 { // cli // - constexpr const char cli_ext_var[] = "extension"; - constexpr const char cli_ext_def[] = "cli"; + extern const char cli_ext_var[] = "extension"; // VC 19 rejects constexpr. + extern const char cli_ext_def[] = "cli"; const target_type cli::static_type { diff --git a/build2/cxx/target.cxx b/build2/cxx/target.cxx index c5b5080..22ace50 100644 --- a/build2/cxx/target.cxx +++ b/build2/cxx/target.cxx @@ -10,9 +10,9 @@ namespace build2 { namespace cxx { - constexpr const char ext_var[] = "extension"; + extern const char ext_var[] = "extension"; // VC 19 rejects constexpr. - constexpr const char hxx_ext_def[] = "hxx"; + extern const char hxx_ext_def[] = "hxx"; const target_type hxx::static_type { "hxx", @@ -24,7 +24,7 @@ namespace build2 false }; - constexpr const char ixx_ext_def[] = "ixx"; + extern const char ixx_ext_def[] = "ixx"; const target_type ixx::static_type { "ixx", @@ -36,7 +36,7 @@ namespace build2 false }; - constexpr const char txx_ext_def[] = "txx"; + extern const char txx_ext_def[] = "txx"; const target_type txx::static_type { "txx", @@ -48,7 +48,7 @@ namespace build2 false }; - constexpr const char cxx_ext_def[] = "cxx"; + extern const char cxx_ext_def[] = "cxx"; const target_type cxx::static_type { "cxx", @@ -60,7 +60,7 @@ namespace build2 false }; - constexpr const char h_ext_def[] = "h"; + extern const char h_ext_def[] = "h"; const target_type h::static_type { "h", @@ -72,7 +72,7 @@ namespace build2 false }; - constexpr const char c_ext_def[] = "c"; + extern const char c_ext_def[] = "c"; const target_type c::static_type { "c", diff --git a/build2/cxx/utility.cxx b/build2/cxx/utility.cxx index 0f4eb08..ed57fd2 100644 --- a/build2/cxx/utility.cxx +++ b/build2/cxx/utility.cxx @@ -36,9 +36,9 @@ namespace build2 // @@ Is mapping for 14 and 17 correct? Maybe Update 2 for 14? // - if ((v == "11" && cver <= 16) || // C++11 since VS2010/10.0. - (v == "14" && cver <= 19) || // C++14 since VS2015/14.0. - (v == "17" && cver <= 20)) // C++17 since VS20??/15.0. + if ((v == "11" && cver < 16) || // C++11 since VS2010/10.0. + (v == "14" && cver < 19) || // C++14 since VS2015/14.0. + (v == "17" && cver < 20)) // C++17 since VS20??/15.0. { fail << "C++" << v << " is not supported by " << cast (rs["cxx.signature"]) << diff --git a/build2/diagnostics b/build2/diagnostics index c0ba6ec..8aedf13 100644 --- a/build2/diagnostics +++ b/build2/diagnostics @@ -140,7 +140,7 @@ namespace build2 diag_record (const diag_mark& m) : empty_ (true), epilogue_ (nullptr) { *this << m;} - ~diag_record () noexcept(false); + ~diag_record () noexcept (false); void append (diag_epilogue e) const @@ -159,30 +159,25 @@ namespace build2 // Move constructible-only type. // - /* - @@ libstdc++ doesn't yet have the ostringstream move support. - + // Older versions of libstdc++ don't have the ostringstream move support + // and accuratly detecting its version is non-trivial. So we always use + // the pessimized implementation with libstdc++. Luckily, GCC doesn't seem + // to be needing move due to copy/move elision. + // diag_record (diag_record&& r) +#ifndef __GLIBCXX__ : os_ (move (r.os_)) - { - empty_ = r.empty_; - r.empty_ = true; - - epilogue_ = r.epilogue_; - r.epilogue_ = nullptr; - } - */ - - diag_record (diag_record&& r) +#endif { empty_ = r.empty_; epilogue_ = r.epilogue_; if (!empty_) { - assert (false); //@@ Stream verbosity will not be transferred. +#ifdef __GLIBCXX__ + stream_verb (os_, stream_verb (r.os_)); os_ << r.os_.str (); - +#endif r.empty_ = true; r.epilogue_ = nullptr; } diff --git a/build2/scope.cxx b/build2/scope.cxx index c9a8ab9..0ef8de6 100644 --- a/build2/scope.cxx +++ b/build2/scope.cxx @@ -540,7 +540,9 @@ namespace build2 return r; } - constexpr const char derived_tt_ext_var[] = "extension"; + // VC 19 rejects constexpr. + // + extern const char derived_tt_ext_var[] = "extension"; pair, bool> scope:: derive_target_type (const string& name, const target_type& base) diff --git a/build2/target.cxx b/build2/target.cxx index 2e500aa..12bbfd1 100644 --- a/build2/target.cxx +++ b/build2/target.cxx @@ -498,8 +498,8 @@ namespace build2 : &extension_pool.find (ext))); } - constexpr const char file_ext_var[] = "extension"; - constexpr const char file_ext_def[] = ""; + extern const char file_ext_var[] = "extension"; // VC 19 rejects constexpr. + extern const char file_ext_def[] = ""; const target_type file::static_type { @@ -613,7 +613,8 @@ namespace build2 false }; - constexpr const char man1_ext[] = "1"; + extern const char man1_ext[] = "1"; // VC 19 rejects constexpr. + const target_type man1::static_type { "man1", diff --git a/build2/variable b/build2/variable index a63b5b4..5b9189c 100644 --- a/build2/variable +++ b/build2/variable @@ -216,7 +216,10 @@ namespace build2 // fit will have to be handled with an extra dynamic allocation. // std::aligned_storage::type data_; - static const size_t size_ = sizeof (data_); + + // VC 19 needs decltype. + // + static const size_t size_ = sizeof (decltype (data_)); // Make sure we have sufficient storage for untyped values. // diff --git a/build2/variable.cxx b/build2/variable.cxx index 65bc023..67efc95 100644 --- a/build2/variable.cxx +++ b/build2/variable.cxx @@ -333,7 +333,7 @@ namespace build2 throw invalid_argument (string ()); } - constexpr const char* const value_traits::type_name = "bool"; + const char* const value_traits::type_name = "bool"; const value_type value_traits::value_type { @@ -373,7 +373,7 @@ namespace build2 throw invalid_argument (string ()); } - constexpr const char* const value_traits::type_name = "uint64"; + const char* const value_traits::type_name = "uint64"; const value_type value_traits::value_type { @@ -459,7 +459,7 @@ namespace build2 return s; } - constexpr const char* const value_traits::type_name = "string"; + const char* const value_traits::type_name = "string"; const value_type value_traits::value_type { @@ -504,7 +504,7 @@ namespace build2 throw invalid_argument (string ()); } - constexpr const char* const value_traits::type_name = "path"; + const char* const value_traits::type_name = "path"; const value_type value_traits::value_type { @@ -547,7 +547,7 @@ namespace build2 throw invalid_argument (string ()); } - constexpr const char* const value_traits::type_name = "dir_path"; + const char* const value_traits::type_name = "dir_path"; const value_type value_traits::value_type { @@ -580,8 +580,7 @@ namespace build2 return abs_dir_path (move (d)); } - constexpr const char* const value_traits::type_name = - "abs_dir_path"; + const char* const value_traits::type_name = "abs_dir_path"; const value_type value_traits::value_type { @@ -616,7 +615,7 @@ namespace build2 return names_view (&v.as (), 1); } - constexpr const char* const value_traits::type_name = "name"; + const char* const value_traits::type_name = "name"; const value_type value_traits::value_type { diff --git a/build2/variable.txx b/build2/variable.txx index 6d3121a..a3511d4 100644 --- a/build2/variable.txx +++ b/build2/variable.txx @@ -275,7 +275,7 @@ namespace build2 value_traits::type_name) + 's'; template - const value_type value_traits>::value_type + const value_type value_traits>::value_type = // VC 19 wants =. { value_traits>::type_name.c_str (), sizeof (vector), @@ -436,7 +436,7 @@ namespace build2 value_traits::type_name + "_map"; template - const value_type value_traits>::value_type + const value_type value_traits>::value_type = // VC 19 wants =. { value_traits>::type_name.c_str (), sizeof (map), -- cgit v1.1