From a4554405706b65c05b6ab0f04807a122b957d0b3 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Tue, 3 Dec 2024 22:25:38 -0700 Subject: [PATCH] cpp: Add c++ version number Several downstream libraries need to specify that they work with c++ 17+ or 20+ and there's no easy way to do this without constantly updating the Kconfig file and supporting different Kconfig versions for different Zephyr versions (since I can't add a dependency on a new c++ standard and have it backwards compatible. Signed-off-by: Yuval Peress --- lib/cpp/Kconfig | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/cpp/Kconfig b/lib/cpp/Kconfig index 728162f5536..da309ee3fbc 100644 --- a/lib/cpp/Kconfig +++ b/lib/cpp/Kconfig @@ -12,6 +12,27 @@ config CPP if CPP +config STD_CPP_VERSION + int + default 199711 if STD_CPP98 + default 201103 if STD_CPP11 + default 201402 if STD_CPP14 + default 201703 if STD_CPP17 + default 202002 if STD_CPP20 || STD_CPP2A || STD_CPP2B + help + The version number of C++ standard being used (NOTE: this uses the + full year and month, and is the same as the __cplusplus macro defined + by the compiler). This config can be used to check for a minimum + supported version. Example: + + depends on STD_CPP_VERSION >= 201703 + + Adding this to your library's enablement Kconfig will force a minimum + c++17 standard. + + The full year is used so c++98 can be checked using > and < operators + without conflicting with c++11 or higher. + choice STD_CPP prompt "C++ Standard" default STD_CPP11