doc: languages: cpp: Add notes about C++ main()

This commit adds notes about the C++ main() function prototype in the
C++ documentation.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
This commit is contained in:
Stephanos Ioannidis 2022-11-05 03:10:09 +09:00 committed by Stephanos Ioannidis
commit 8073115b4c

View file

@ -24,6 +24,12 @@ on the suffix (extension) of the files. Files identified with either a **cpp**
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`` while Zephyr uses ``void`` by default. If your ``main()`` is defined in
a C++ source file, you must select :kconfig:option:`CONFIG_CPP_MAIN` in the
application configuration file so that Zephyr uses ``int main(void)`` instead
of ``void main(void)``.
.. note::
Do not use C++ for kernel, driver, or system initialization code.