|
1 | | -Using C++ in RIOT {#using-cpp} |
2 | | -================= |
| 1 | +Using C++ in RIOT {#using-cpp} |
| 2 | +================== |
3 | 3 |
|
4 | | -[TOC] |
5 | | - |
6 | | -Levels of Support {#levels-of-support} |
7 | | -================= |
8 | | - |
9 | | -A CPU in RIOT can have three levels of support for C++ code: |
10 | | - |
11 | | -1. No support for C++ at all |
12 | | -2. C++ is supported, but no libstdc++ implementation is available |
13 | | -3. C++ is supported and a libstdc++ implementation is available |
14 | | - |
15 | | -The reason for missing or only partial C++ support can be one (or more) of |
16 | | -the following: |
17 | | - |
18 | | -- No libstdc++ implementation for the target platform is available to RIOT, or |
19 | | - the official RIOT docker image is missing it |
20 | | -- Missing toolchain support for a given target platform |
21 | | -- The C++ toolchain requires library code (such as constructor guards for the |
22 | | - thread safe initialization of statically allocated instances) or hooks in |
23 | | - the startup process to perform initialization |
24 | | - |
25 | | -Using C++ |
26 | | -========= |
27 | | - |
28 | | -In order for C++ code to compile with RIOT, the following needs to be done: |
29 | | - |
30 | | -- All C++ files must have the file extension `.cpp`, all C++ headers `.hpp` |
31 | | - - For external code, overwriting the make variable `SRCXXEXT` e.g. to |
32 | | - `cxx` can be used to compile C++ files with other extensions, e.g. `.cxx` |
33 | | -- `FEATURES_REQUIRED += cpp` must be added to the applications `Makefile` |
34 | | - - If additionally the libstdc++ is used, `FEATURES_REQUIRED += libstdcpp` |
35 | | - must be used additionally |
36 | | - |
37 | | -RIOT Modules in C++ {#cpp-in-riot} |
38 | | -=================== |
39 | | - |
40 | | -RIOT modules should be written in C, so that boards/platforms without or partial |
41 | | -C++ support can still use these modules. However, external modules, packages, |
42 | | -and modules that require C++ support anyway (e.g. the Arduino compatibility |
43 | | -features) can be written in C++. Also, some modules might be designed as |
44 | | -compatibility layer for C++ or provide convenient access to RIOT-OS' features |
45 | | -using C++ APIs. These modules/packages have to depend on the |
46 | | -`cpp` feature (`FEATURES_REQUIRED += cpp`) and possibly the `libstdcpp` |
47 | | -feature using their `Makefile.dep`. |
48 | | - |
49 | | -See Also {#see-also} |
50 | | -======== |
51 | | - |
52 | | -Reference @ref cpp for a list of C++ modules. |
| 4 | +@deprecated Guides have moved to the [Guide Site](https://guide.riot-os.org/c_tutorials/using_cpp/). |
| 5 | +This page will be removed after release 2026.04. |
0 commit comments