From cefb043b7f2c103b2477709b1f222659ba1fdc67 Mon Sep 17 00:00:00 2001 From: Skittles Date: Wed, 22 Apr 2026 22:06:15 -0700 Subject: [PATCH] Use C++ 23 --- app/CMakeLists.txt | 2 +- app/prj.conf | 4 ++++ app/src/{main.c => main.cpp} | 5 +++-- 3 files changed, 8 insertions(+), 3 deletions(-) rename app/src/{main.c => main.cpp} (80%) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 01ecff8..f639f6c 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -9,7 +9,7 @@ find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(app LANGUAGES C) -target_sources(app PRIVATE src/main.c) +target_sources(app PRIVATE src/main.cpp) # The code below locates the git index file for this repository and adds it as a dependency for # the application VERSION file so that if the repo has a new commit added, even if no files in diff --git a/app/prj.conf b/app/prj.conf index ac51ec3..3357cc9 100644 --- a/app/prj.conf +++ b/app/prj.conf @@ -3,5 +3,9 @@ # # This file contains selected Kconfig options for the application. +# C++ +CONFIG_CPP=y +CONFIG_STD_CPP23=y + CONFIG_SENSOR=y CONFIG_BLINK=y diff --git a/app/src/main.c b/app/src/main.cpp similarity index 80% rename from app/src/main.c rename to app/src/main.cpp index c43bc3c..888e381 100644 --- a/app/src/main.c +++ b/app/src/main.cpp @@ -10,10 +10,11 @@ LOG_MODULE_REGISTER(main, CONFIG_APP_LOG_LEVEL); -int main(void) { +int main() { printk("Zephyr Example Application %s\n", APP_VERSION_STRING); + printk("Build with C++ standard: %ldL\n", __cplusplus); - while (1) { + while (true) { printk("Running...\n"); k_sleep(K_SECONDS(5)); }