diff --git a/modules/vstudio/tests/vc2010/test_compile_settings.lua b/modules/vstudio/tests/vc2010/test_compile_settings.lua index c15096c40..8f56cc635 100644 --- a/modules/vstudio/tests/vc2010/test_compile_settings.lua +++ b/modules/vstudio/tests/vc2010/test_compile_settings.lua @@ -1477,6 +1477,22 @@ ]] end + function suite.onLanguage_C23_VS2019() + p.action.set("vs2019") + + cdialect 'C23' + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + stdclatest + Level3 + + ]] + end + function suite.onLanguage_CppLatest_VS2010() cppdialect 'C++latest' prepare() diff --git a/modules/vstudio/vs2010_vcxproj.lua b/modules/vstudio/vs2010_vcxproj.lua index 08901c9bc..6624945f3 100644 --- a/modules/vstudio/vs2010_vcxproj.lua +++ b/modules/vstudio/vs2010_vcxproj.lua @@ -2064,6 +2064,8 @@ m.element("LanguageStandard_C", condition, 'stdc11') elseif (cfg.cdialect == "C17") then m.element("LanguageStandard_C", condition, 'stdc17') + elseif (cfg.cdialect == "C23") then + m.element("LanguageStandard_C", condition, 'stdclatest') end end end diff --git a/modules/xcode/tests/test_xcode_project.lua b/modules/xcode/tests/test_xcode_project.lua index e05ec4ccc..758e98c03 100644 --- a/modules/xcode/tests/test_xcode_project.lua +++ b/modules/xcode/tests/test_xcode_project.lua @@ -3445,6 +3445,58 @@ ]] end + function suite.XCBuildConfigurationProject_OnC17() + workspace("MyWorkspace") + cdialect("C17") + prepare() + xcode.XCBuildConfiguration_Project(tr, tr.configs[1]) + test.capture [[ + A14350AC4595EE5E57CE36EC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(NATIVE_ARCH_ACTUAL)"; + CONFIGURATION_BUILD_DIR = "$(SYMROOT)"; + CONFIGURATION_TEMP_DIR = "$(OBJROOT)"; + GCC_C_LANGUAGE_STANDARD = c17; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + OBJROOT = obj/Debug; + ONLY_ACTIVE_ARCH = NO; + SYMROOT = bin/Debug; + }; + name = Debug; + }; + ]] + end + + function suite.XCBuildConfigurationProject_OnC23() + workspace("MyWorkspace") + cdialect("C23") + prepare() + xcode.XCBuildConfiguration_Project(tr, tr.configs[1]) + test.capture [[ + A14350AC4595EE5E57CE36EC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(NATIVE_ARCH_ACTUAL)"; + CONFIGURATION_BUILD_DIR = "$(SYMROOT)"; + CONFIGURATION_TEMP_DIR = "$(OBJROOT)"; + GCC_C_LANGUAGE_STANDARD = c23; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + OBJROOT = obj/Debug; + ONLY_ACTIVE_ARCH = NO; + SYMROOT = bin/Debug; + }; + name = Debug; + }; + ]] + end + function suite.XCBuildConfigurationProject_OnGnu89() workspace("MyWorkspace") cdialect("gnu89") @@ -3549,6 +3601,58 @@ ]] end + function suite.XCBuildConfigurationProject_OnGnu17() + workspace("MyWorkspace") + cdialect("gnu17") + prepare() + xcode.XCBuildConfiguration_Project(tr, tr.configs[1]) + test.capture [[ + A14350AC4595EE5E57CE36EC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(NATIVE_ARCH_ACTUAL)"; + CONFIGURATION_BUILD_DIR = "$(SYMROOT)"; + CONFIGURATION_TEMP_DIR = "$(OBJROOT)"; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + OBJROOT = obj/Debug; + ONLY_ACTIVE_ARCH = NO; + SYMROOT = bin/Debug; + }; + name = Debug; + }; + ]] + end + + function suite.XCBuildConfigurationProject_OnGnu23() + workspace("MyWorkspace") + cdialect("gnu23") + prepare() + xcode.XCBuildConfiguration_Project(tr, tr.configs[1]) + test.capture [[ + A14350AC4595EE5E57CE36EC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(NATIVE_ARCH_ACTUAL)"; + CONFIGURATION_BUILD_DIR = "$(SYMROOT)"; + CONFIGURATION_TEMP_DIR = "$(OBJROOT)"; + GCC_C_LANGUAGE_STANDARD = gnu23; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + OBJROOT = obj/Debug; + ONLY_ACTIVE_ARCH = NO; + SYMROOT = bin/Debug; + }; + name = Debug; + }; + ]] + end + function suite.XCBuildConfigurationProject_OnCppDefault() workspace("MyWorkspace") cppdialect("Default") diff --git a/modules/xcode/xcode_common.lua b/modules/xcode/xcode_common.lua index 3997bdb8e..c9f400855 100644 --- a/modules/xcode/xcode_common.lua +++ b/modules/xcode/xcode_common.lua @@ -1369,10 +1369,14 @@ ["C90"] = "c90", ["C99"] = "c99", ["C11"] = "c11", + ["C17"] = "c17", + ["C23"] = "c23", ["gnu89"] = "gnu89", ["gnu90"] = "gnu90", ["gnu99"] = "gnu99", - ["gnu11"] = "gnu11" + ["gnu11"] = "gnu11", + ["gnu17"] = "gnu17", + ["gnu23"] = "gnu23", } function xcode.XCBuildConfiguration_CLanguageStandard(settings, cfg) diff --git a/src/_premake_init.lua b/src/_premake_init.lua index dd13bd24f..99a4ab996 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -491,11 +491,13 @@ "C99", "C11", "C17", + "C23", "gnu89", "gnu90", "gnu99", "gnu11", - "gnu17" + "gnu17", + "gnu23", } } diff --git a/src/tools/gcc.lua b/src/tools/gcc.lua index afec2efe3..24dd3874c 100644 --- a/src/tools/gcc.lua +++ b/src/tools/gcc.lua @@ -172,11 +172,13 @@ ["C99"] = "-std=c99", ["C11"] = "-std=c11", ["C17"] = "-std=c17", + ["C23"] = "-std=c23", ["gnu89"] = "-std=gnu89", ["gnu90"] = "-std=gnu90", ["gnu99"] = "-std=gnu99", ["gnu11"] = "-std=gnu11", - ["gnu17"] = "-std=gnu17" + ["gnu17"] = "-std=gnu17", + ["gnu23"] = "-std=gnu23", } } diff --git a/src/tools/msc.lua b/src/tools/msc.lua index f62498c3e..68170b03e 100644 --- a/src/tools/msc.lua +++ b/src/tools/msc.lua @@ -179,7 +179,8 @@ msc.cflags = { cdialect = { ["C11"] = "/std:c11", - ["C17"] = "/std:c17" + ["C17"] = "/std:c17", + ["C23"] = "/std:clatest" } } diff --git a/tests/tools/test_gcc.lua b/tests/tools/test_gcc.lua index fbcdee943..411fac8bc 100644 --- a/tests/tools/test_gcc.lua +++ b/tests/tools/test_gcc.lua @@ -947,6 +947,13 @@ end test.isequal({ }, gcc.getcxxflags(cfg)) end + function suite.cflags_onC23() + cdialect "C23" + prepare() + test.contains({ "-std=c23" }, gcc.getcflags(cfg)) + test.isequal({ }, gcc.getcxxflags(cfg)) + end + function suite.cflags_ongnu89() cdialect "gnu89" prepare() @@ -982,6 +989,13 @@ end test.isequal({ }, gcc.getcxxflags(cfg)) end + function suite.cflags_ongnu23() + cdialect "gnu23" + prepare() + test.contains({ "-std=gnu23" }, gcc.getcflags(cfg)) + test.isequal({ }, gcc.getcxxflags(cfg)) + end + function suite.cxxflags_onCppDefault() cppdialect "Default" prepare() diff --git a/tests/tools/test_msc.lua b/tests/tools/test_msc.lua index 56252cf83..6d4a20602 100644 --- a/tests/tools/test_msc.lua +++ b/tests/tools/test_msc.lua @@ -390,6 +390,12 @@ end test.contains('/std:c17', msc.getcflags(cfg)) end + function suite.cdialectC23() + cdialect "C23" + prepare() + test.contains('/std:clatest', msc.getcflags(cfg)) + end + -- -- Check handling of cppdialect. -- diff --git a/website/docs/cdialect.md b/website/docs/cdialect.md index 8a92002d0..bd3024fe9 100644 --- a/website/docs/cdialect.md +++ b/website/docs/cdialect.md @@ -14,11 +14,13 @@ cdialect "value" * `C99`: ISO C99 * `C11`: ISO C11 * `C17`: ISO C17 +* `C23`: ISO C23 * `gnu89`: GNU dialect of ISO C89 * `gnu90`: GNU dialect of ISO C90 * `gnu99`: GNU dialect of ISO C99 * `gnu11`: GNU dialect of ISO C11 * `gnu17`: GNU dialect of ISO C17 +* `gnu23`: GNU dialect of ISO C23 ### Applies To ###