From 7d4a7d79a8a67ea7abd0f0a2775cf89d0bc8f772 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 5 Apr 2023 09:14:10 -0700 Subject: [PATCH] doc/releases: Note "main" return type change for 3.4 Add a paragraph explaining the change from void main(void) to int main(void) and the requirement for main functions to return zero. Signed-off-by: Keith Packard --- doc/releases/release-notes-3.4.rst | 11 +++++++++++ samples/hello_world/src/main.c | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/releases/release-notes-3.4.rst b/doc/releases/release-notes-3.4.rst index 126029acfc8..48b782747ef 100644 --- a/doc/releases/release-notes-3.4.rst +++ b/doc/releases/release-notes-3.4.rst @@ -129,6 +129,17 @@ Changes in this release * Touchscreen drivers converted to use the input APIs can use the :dtcompatible:`zephyr,kscan-input` driver to maintain Kscan compatilibity. +* The declaration of :c:func:`main` has been changed from ``void + main(void)`` to ``int main(void)``. The main function is required to + return the value zero. All other return values are reserved. This aligns + Zephyr with the C and C++ language specification requirements for + "hosted" environments, avoiding compiler warnings and errors. These + compiler messages are generated when applications are built in "hosted" + mode (which means without the ``-ffreestanding`` compiler flag). As the + ``-ffreestanding`` flag is currently enabled unless the application is + using picolibc, only applications using picolibc will be affected by this + change at this time. + Removed APIs in this release ============================ diff --git a/samples/hello_world/src/main.c b/samples/hello_world/src/main.c index bc7a4c1d716..133ddd5048f 100644 --- a/samples/hello_world/src/main.c +++ b/samples/hello_world/src/main.c @@ -6,8 +6,8 @@ #include -int main(void) +void main(void) { printk("Hello World! %s\n", CONFIG_BOARD); - return 0; + return; }