RTEMS with C++

Chris Johns chrisj at rtems.org
Tue Oct 10 12:09:35 UTC 2006


Fabrício de Novaes Kucinskis wrote:
> 
> I'd like to know if someone here uses C++ with RTEMS.
>

I do and so do a number of the people I consult too.

> What are the advantages? I see just disadvantages, such as the obvious
> overhead.

The general arguments for and against C++ should apply when used with 
RTEMS. Decide on using C++ based on your application rather than a fit 
of C++ to RTEMS.

You can write efficient code in C++ with the same overhead as C. I am 
working on a class for a high data rate HDLC controller all written in C++.

> 
> I don't see a good use for objects instantiated inside only one task (maybe
> the encapsulation of the code?), and since the communication between objects
> in different tasks should be done through the RTEMS managers, I think
> there's no reason to use C++ and OO in a RTEMS application. But I'd like to
> be convinced that C++ in RTEMS is something good.
> 

I tend to look at classes and threads in the opposite way. I write a 
class for a specific purpose and if it needs a thread I embed one in 
that class where a member function is the thread body. At an upper level 
of the design I use an instance of that class or more than one instance 
and I do not have to consider the threads involved.

> One more question: does the "librtems++" switch link the OO wrappers to the
> managers?

The wrapper classes are all separate and should only reference the 
managers they use so if you do not use a class it should not pull in 
manager.

Regards
Chris



More information about the users mailing list