Is there any reason to use C instead of C++ for embedded development?
- by Piotr Czapla
Question
I have two compilers on my hardware C++ and C89
I'm thinking about using C++ with classes but without polymorphism (to avoid vtables).
The main reasons I’d like to use C++ are:
I prefer to use “inline” functions instead of macro definitions.
I’d like to use namespaces as I prefixes clutter the code.
I see C++ a bit type safer mainly because of templates, and verbose casting.
I really like overloaded functions and constructors (used for automatic casting).
Do you see any reason to stick with C89 when developing for very limited hardware (4kb of RAM)?
Conclusion
Thank you for your answers, they were really helpful!
I though the subject through and I will stick with C mainly because:
It is easier to predict actual code in C and this is really important if you have only 4kb of ram.
My team consists of C developers mainly so advance features of C++ won't be frequently used.
I've found a way to inline functions in my C compiler (C89).
It is hard to accept one answer as you provided so many good answers.
Unfortunately I can't create a wiki and accept it so I will choose one answer that made me think most.