Selected C++ Features
We don't enable Embedded C++ (EC++) since it disables most features of C++. Instead, we only disable some C++ features which will cause performance penalty, especially the "Exceptions" and "RTTI" features which are already disabled by default.
| C++ Language Feature | Performance Penalty | EC++ Subset | Our Choice |
|---|---|---|---|
| Classes | No | Yes | Yes |
| Overloading | No | Yes | Yes |
| Operator Overloading | No | Yes | Yes |
| Inheritance (derived classes) | No | Yes | Yes |
| Wide Character Support | No | Yes | UTF-8 |
| Multiple Inheritance | No | No | Yes |
| Templates | No | No | Yes |
| Namespaces | No | No | Yes |
| Polymorphism (virtual functions) | Only when used | Yes | Yes |
| Virtual Base Classes | Only when used | No | Yes |
| Dynamic Casts | Only when used | No | Yes |
| Run-time Type Identification (RTTI) | Yes, even not used | No | No |
| Exceptions | Severe, even not used | No | No |
TI C++ compilers supply a full implementation of the C++ library, including the STL. The C++ additions to the library are obtained from Dinkumware, a world class supplier of C++ libraries.
Task Encapsulation
It will be more convenient if RTOS can provide encapsulated C++ classes for task run-loop. PicOS has built-in a Task class to simplify the usage.
class MyTask: public pos::Task
{
private:
int x;
public:
MyTask();
~ MyTask();
run();
};
void MyTask::run()
{
while(1){
msg_t msg;
if(msgPend(&msg, 1000)){
switch(msg.MsgID){
case MSG_KEY_DOWN:
...
break;
case ...
}
}
}
}