From 8b8b0a0b4ac8b82a72051df165991e8c7d945103 Mon Sep 17 00:00:00 2001 From: Jakub Michalski Date: Mon, 12 Aug 2024 10:48:09 +0200 Subject: [PATCH] docs: add information about main(int, char **) Add information about main(int, argc **) in places where the documentation stated that only parameterless main could be used Signed-off-by: Jakub Michalski Signed-off-by: Filip Kokosinski --- doc/develop/languages/cpp/index.rst | 7 ++++--- doc/kernel/services/threads/system_threads.rst | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/develop/languages/cpp/index.rst b/doc/develop/languages/cpp/index.rst index d075a47319b..86b994c06d3 100644 --- a/doc/develop/languages/cpp/index.rst +++ b/doc/develop/languages/cpp/index.rst @@ -31,9 +31,10 @@ or a **cxx** suffix are compiled using the C++ compiler. For example, :file:`myCplusplusApp.cpp` is compiled using C++. The C++ standard requires the ``main()`` function to have the return type of -``int``. Your ``main()`` must be defined as ``int main(void)``. Zephyr ignores -the return value from main, so applications should not return status -information and should, instead, return zero. +``int``. Your ``main()`` must be defined as ``int main(void)`` or +``int main(int, char **)``. To use main with arguments the ``CONFIG_BOOTARGS`` option +has to be selected. Zephyr ignores the return value from main, so applications +should not return status information and should, instead, return zero. .. note:: Do not use C++ for kernel, driver, or system initialization code. diff --git a/doc/kernel/services/threads/system_threads.rst b/doc/kernel/services/threads/system_threads.rst index cd5bb7f4d87..74da3c0a033 100644 --- a/doc/kernel/services/threads/system_threads.rst +++ b/doc/kernel/services/threads/system_threads.rst @@ -53,11 +53,12 @@ Implementation Writing a main() function ========================= -An application-supplied :c:func:`main` function begins executing once +An application-supplied ``main()`` function begins executing once kernel initialization is complete. The kernel does not pass any arguments -to the function. +to the function, unless ``CONFIG_BOOTARGS`` is selected. In such case the +kernel passes arguments to it and ``main(int, char **)`` can be used. -The following code outlines a trivial :c:func:`main` function. +The following code outlines a trivial ``main(void)`` function. The function used by a real application can be as complex as needed. .. code-block:: c