Topics

C++ user apps


Simon Glass
 

Hi,

Is there any guidance about using C++ in Zephyr? Is it common / recommended?

Does anyone have a link to a previous discussion?

Regards,
Simon


Peter A. Bigot
 

The meta-issue is: https://github.com/zephyrproject-rtos/zephyr/issues/18554

I personally am using C++20 but haven't got language-independent functionality to the point where I can really start making progress in a real application.  Generally C++ should work at application level and you stick to basic language capabilities avoiding things like atomic, thread, and (to some degree) exceptions.

Peter


Kim Bøndergaard
 


For application code it seems to be OK. You just have to enable it properly in your config:
Some of the configs I've been using:

CONFIG_STD_CPP11=y / CONFIG_STD_CPP14=y
CONFIG_NEWLIB_LIBC=y
CONFIG_CPLUSPLUS=y
CONFIG_LIB_CPLUSPLUS=y
CONFIG_RTTI=y

Beware of some of the pitfalls with e.g. exceptions.

Kim Bøndergaard
Prevas A/S
Team Manager / Systems Architect
 
Hedeager 3, DK-8200 Aarhus N

Phone +45 3315 9090
Mobile +45 5154 3961
kibo@... 
www.prevas.dk

 

 


From: devel@... <devel@...> on behalf of Simon Glass via lists.zephyrproject.org <sjg=chromium.org@...>
Sent: Monday, August 24, 2020 17:17
To: devel <devel@...>
Subject: [Zephyr-devel] C++ user apps
 
Hi,

Is there any guidance about using C++ in Zephyr? Is it common / recommended?

Does anyone have a link to a previous discussion?

Regards,
Simon




Simon Glass <sjg@...>
 

Hi,

Thank you for the info!

Regards,
Simon

On Mon, 24 Aug 2020 at 23:54, Kim Bøndergaard <Kim.Bondergaard@...> wrote:

See https://docs.zephyrproject.org/latest/reference/kernel/other/cxx_support.html?highlight=cxx

For application code it seems to be OK. You just have to enable it properly in your config:
Some of the configs I've been using:

CONFIG_STD_CPP11=y / CONFIG_STD_CPP14=y
CONFIG_NEWLIB_LIBC=y
CONFIG_CPLUSPLUS=y
CONFIG_LIB_CPLUSPLUS=y
CONFIG_RTTI=y

Beware of some of the pitfalls with e.g. exceptions.

Kim Bøndergaard
Prevas A/S
Team Manager / Systems Architect

Hedeager 3, DK-8200 Aarhus N

Phone +45 3315 9090
Mobile +45 5154 3961
kibo@...
www.prevas.dk




________________________________
From: devel@... <devel@...> on behalf of Simon Glass via lists.zephyrproject.org <sjg=chromium.org@...>
Sent: Monday, August 24, 2020 17:17
To: devel <devel@...>
Subject: [Zephyr-devel] C++ user apps

Hi,

Is there any guidance about using C++ in Zephyr? Is it common / recommended?

Does anyone have a link to a previous discussion?

Regards,
Simon