Making Rtems Device Drivers using C?

Chris Johns chrisj at
Tue Jan 4 21:46:54 UTC 2005

Angelo Fraietta wrote:
> Surely the overhead in C++ would only be if calls were being made to C++ 
> run time libraries from within the interrupt.

Overhead is not the issue. Joel is making a general point about C++ and 
device drivers, and to be more specific drivers with interrupts. You 
need to know more about what is happening to make the code work as you 
expect. For example you can not throw exceptions from an ISR and catch 
them in a task, and accessing a STL container in an ISR could result in 
the code trying to lock a mutex, or there could be temporary objects 
that try to use the heap. I suspect there are more conditions.

> Would calling a native RTEMS set event from code compiled with the C++ 
> compiler be different from making the same call from within the C compiler?

No different. I use C++ for all application development.

> Michael Barr, in book cited below,  states that C++ is preferable due to 
> its type-safety. Overhead can be controlled by avoiding things such as 
> templates.
> 1.    Barr, M., Programming embedded systems in C and C++. 1999, 
> Sebastopol, Calif.: O'Reilly. xvii, 174.

Not sure I agree with the last statement about templates.

  Chris Johns

More information about the users mailing list