What features of C++ should be avoided in embedded systems?
Please classify the answer by reason such as:
EDIT: Lets' use an ARM7TDMI with 64k ram as a target to control the scope of the answers.
Although not originally designed for embedded software development, the C language allows a range of programming styles from high-level application code down to direct low-level manipulation of hardware registers. As a result, C has become the most popular programming language for embedded systems today.
For many embedded systems, C or C++ will be the best choices. In part, that's because they are “compiled” languages and extremely efficient. In compiled languages, the machine (or embedded device) directly translates the code, which means the language is fast and stable.
C is a much smaller language to write a compiler for, so a lot of small CPUs have a C compiler available. C++ is massively more difficult, so doesn't often happen. As a result, you can rely on C code for any given chip, but less so having C++ available. This trains embedded coders to use C as their main language.
C gives you much more control than C++. Show activity on this post. I've written some code for ARM7 embedded paltform on IAR Workbench.
RTTI and Exception Handling:
Templates:
Virtual functions and inheritance:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With