From d228d6e33b460be975ac0a0325a94a7f3307c0e2 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 14 May 2024 09:16:23 +0200 Subject: Map C23/C2X to /std:clatest starting from MSVC 17.9 (19.39) In particular, this option enables C23 typeof support. --- libbuild2/c/init.cxx | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'libbuild2/c') 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; } -- cgit v1.1