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 <jmichalski@internships.antmicro.com>
Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
This commit is contained in:
Jakub Michalski 2024-08-12 10:48:09 +02:00 committed by Mahesh Mahadevan
commit 8b8b0a0b4a
2 changed files with 8 additions and 6 deletions

View file

@ -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.

View file

@ -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