From a276fe8ee909d1122cfebf098669fffd9ffe05b0 Mon Sep 17 00:00:00 2001 From: Nicholaus Clark Date: Sat, 6 Nov 2021 12:19:58 -0500 Subject: [PATCH] Changed C++20 to emit C++20 instead of C++Latest in MSVC, Added C11 and C17 --- .../tests/vc2010/test_compile_settings.lua | 47 ++++++++++++++++++- modules/vstudio/vs2010_vcxproj.lua | 15 +++++- src/_premake_init.lua | 1 + website/docs/cdialect.md | 1 + 4 files changed, 62 insertions(+), 2 deletions(-) diff --git a/modules/vstudio/tests/vc2010/test_compile_settings.lua b/modules/vstudio/tests/vc2010/test_compile_settings.lua index 4f13aa04..1894873c 100644 --- a/modules/vstudio/tests/vc2010/test_compile_settings.lua +++ b/modules/vstudio/tests/vc2010/test_compile_settings.lua @@ -1338,6 +1338,21 @@ ]] end + function suite.onLanguage_Cpp20_VS2017() + p.action.set("vs2017") + + cppdialect 'C++20' + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + stdcpplatest + + ]] + end + function suite.onLanguage_Cpp20_VS2019() p.action.set("vs2019") @@ -1348,7 +1363,37 @@ NotUsing Level3 Disabled - stdcpplatest + stdcpp20 + + ]] + end + + function suite.onLanguage_C11_VS2019() + p.action.set("vs2019") + + cdialect 'C11' + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + stdc11 + + ]] + end + + function suite.onLanguage_C17_VS2019() + p.action.set("vs2019") + + cdialect 'C17' + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + stdc17 ]] end diff --git a/modules/vstudio/vs2010_vcxproj.lua b/modules/vstudio/vs2010_vcxproj.lua index e81c8320..de21df21 100644 --- a/modules/vstudio/vs2010_vcxproj.lua +++ b/modules/vstudio/vs2010_vcxproj.lua @@ -389,6 +389,7 @@ m.compileAs, m.callingConvention, m.languageStandard, + m.languageStandardC, m.conformanceMode, m.structMemberAlignment, m.useFullPaths, @@ -1477,13 +1478,25 @@ elseif (cfg.cppdialect == "C++17") then m.element("LanguageStandard", nil, 'stdcpp17') elseif (cfg.cppdialect == "C++20") then - m.element("LanguageStandard", nil, 'stdcpplatest') + m.element("LanguageStandard", nil, iif(_ACTION == "vs2017", 'stdcpplatest', 'stdcpp20')) elseif (cfg.cppdialect == "C++latest") then m.element("LanguageStandard", nil, 'stdcpplatest') end end end + + function m.languageStandardC(cfg) + if _ACTION >= "vs2019" then + if (cfg.cdialect == "C11") then + m.element("LanguageStandard_C", nil, 'stdc11') + elseif (cfg.cdialect == "C17") then + m.element("LanguageStandard_C", nil, 'stdc17') + end + end + end + + function m.conformanceMode(cfg) if _ACTION >= "vs2017" then if cfg.conformancemode ~= nil then diff --git a/src/_premake_init.lua b/src/_premake_init.lua index 2e18c53d..7a95b8da 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -757,6 +757,7 @@ "C90", "C99", "C11", + "C17", "gnu89", "gnu90", "gnu99", diff --git a/website/docs/cdialect.md b/website/docs/cdialect.md index ae79a3cd..1687a99a 100644 --- a/website/docs/cdialect.md +++ b/website/docs/cdialect.md @@ -13,6 +13,7 @@ cdialect "value" * `C90`: ISO C90 * `C99`: ISO C99 * `C11`: ISO C11 +* `C17`: ISO C17 * `gnu89`: GNU dialect of ISO C89 * `gnu90`: GNU dialect of ISO C90 * `gnu99`: GNU dialect of ISO C99