aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-05-14 09:16:23 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-05-14 09:16:23 +0200
commitd228d6e33b460be975ac0a0325a94a7f3307c0e2 (patch)
tree69924b66dd533ff1b1e496520d3a8137079e5500
parentcfe4db0858677230a1b8e06e8b965bc580e3c97a (diff)
Map C23/C2X to /std:clatest starting from MSVC 17.9 (19.39)
In particular, this option enables C23 typeof support.
-rw-r--r--libbuild2/c/init.cxx26
-rw-r--r--libbuild2/cxx/init.cxx6
2 files changed, 20 insertions, 12 deletions
diff --git a/libbuild2/c/init.cxx b/libbuild2/c/init.cxx
index 8bc2f7d..f100abc 100644
--- a/libbuild2/c/init.cxx
+++ b/libbuild2/c/init.cxx
@@ -111,23 +111,31 @@ namespace build2
// From version 16.8 VC now supports /std:c11 and /std:c17 options
// which enable C11/17 conformance. However, as of version 16.10,
// neither SDK nor CRT can be compiled in these modes (see the /std
- // option documentation for details/updates).
+ // option documentation for details/updates). There is also now
+ // /std:clatest which can be used to enable C23 typeof as of MSVC
+ // 17.9. So let's map C23 to that.
//
if (v == nullptr)
;
else if (!stdcmp ("90"))
{
- uint64_t cver (ci.version.major);
-
- if ((stdcmp ("99") && cver < 16) || // Since VS2010/10.0.
- ((stdcmp ("11") ||
- stdcmp ("17") ||
- stdcmp ("18")) && cver < 18) || // Since VS????/11.0.
- (stdcmp ("23", "2x") ))
+ uint64_t mj (ci.version.major);
+ uint64_t mi (ci.version.minor);
+
+ if (stdcmp ("99") && mj >= 16) // Since VS2010/10.0.
+ ;
+ else if ((stdcmp ("11") ||
+ stdcmp ("17") ||
+ stdcmp ("18")) && mj >= 18) // Since VS????/11.0.
+ ;
+ else if (stdcmp ("23", "2x") &&
+ (mj > 19 || (mj == 19 && mi >= 39))) // Since 17.9.
{
+ mode.insert (mode.begin (), "/std:clatest");
+ }
+ else
fail << "C " << *v << " is not supported by " << ci.signature <<
info << "required by " << project (rs) << '@' << rs;
- }
}
break;
}
diff --git a/libbuild2/cxx/init.cxx b/libbuild2/cxx/init.cxx
index 8159d18..0c29d41 100644
--- a/libbuild2/cxx/init.cxx
+++ b/libbuild2/cxx/init.cxx
@@ -498,8 +498,8 @@ namespace build2
// Unless disabled by the user, try to enable C++ modules.
//
- // NOTE: see also diagnostics about modules support required in compile
- // rule.
+ // NOTE: see also diagnostics about modules support required (if
+ // attempting to use) in compile rule.
//
if (!modules.value || *modules.value)
{
@@ -580,7 +580,7 @@ namespace build2
// around Clang 16 so we don't support anything earlier than
// that (it's not practically usable anyway).
//
- // Clang enable modules by default in c++20 or later but they
+ // Clang enables modules by default in c++20 or later but they
// don't yet (as of Clang 18) define __cpp_modules. When they
// do, we can consider enabling modules by default on our side.
// For now, we only enable modules if forced with explicit