aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/c/init.cxx
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 /libbuild2/c/init.cxx
parentcfe4db0858677230a1b8e06e8b965bc580e3c97a (diff)
Map C23/C2X to /std:clatest starting from MSVC 17.9 (19.39)
In particular, this option enables C23 typeof support.
Diffstat (limited to 'libbuild2/c/init.cxx')
-rw-r--r--libbuild2/c/init.cxx26
1 files changed, 17 insertions, 9 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;
}