A CPU in RIOT can have three levels of support for C++ code:
The reason for missing or only partial C++ support can be one (or more) of the following:
In order for C++ code to compile with RIOT, the following needs to be done:
.cpp
, all C++ headers .hpp
SRCXXEXT
e.g. to cxx
can be used to compile C++ files with other extensions, e.g. .cxx
FEATURES_REQUIRED += cpp
must be added to the applications Makefile
FEATURES_REQUIRED += libstdcpp
must be used additionallyRIOT modules should be written in C, so that boards/platforms without or partial C++ support can still use these modules. However, external modules, packages, and modules that require C++ support anyway (e.g. the Arduino compatibility features) can be written in C++. Also, some modules might be designed as compatibility layer for C++ or provide convenient access to RIOT-OS' features using C++ APIs. These modules/packages have to depend on the cpp
feature (FEATURES_REQUIRED += cpp
) and possibly the libstdcpp
feature using their Makefile.dep
.
Reference C++ for a list of C++ modules.