Skip to content

Commit 8b8b0a0

Browse files
jmichalski-antmmahadevan108
authored andcommitted
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 <[email protected]> Signed-off-by: Filip Kokosinski <[email protected]>
1 parent 5b1f6f3 commit 8b8b0a0

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

doc/develop/languages/cpp/index.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ or a **cxx** suffix are compiled using the C++ compiler. For example,
3131
:file:`myCplusplusApp.cpp` is compiled using C++.
3232

3333
The C++ standard requires the ``main()`` function to have the return type of
34-
``int``. Your ``main()`` must be defined as ``int main(void)``. Zephyr ignores
35-
the return value from main, so applications should not return status
36-
information and should, instead, return zero.
34+
``int``. Your ``main()`` must be defined as ``int main(void)`` or
35+
``int main(int, char **)``. To use main with arguments the ``CONFIG_BOOTARGS`` option
36+
has to be selected. Zephyr ignores the return value from main, so applications
37+
should not return status information and should, instead, return zero.
3738

3839
.. note::
3940
Do not use C++ for kernel, driver, or system initialization code.

doc/kernel/services/threads/system_threads.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,12 @@ Implementation
5353
Writing a main() function
5454
=========================
5555

56-
An application-supplied :c:func:`main` function begins executing once
56+
An application-supplied ``main()`` function begins executing once
5757
kernel initialization is complete. The kernel does not pass any arguments
58-
to the function.
58+
to the function, unless ``CONFIG_BOOTARGS`` is selected. In such case the
59+
kernel passes arguments to it and ``main(int, char **)`` can be used.
5960

60-
The following code outlines a trivial :c:func:`main` function.
61+
The following code outlines a trivial ``main(void)`` function.
6162
The function used by a real application can be as complex as needed.
6263

6364
.. code-block:: c

0 commit comments

Comments
 (0)