Possible Duplicate:
Is there any reason to use C instead of C++ for embedded development?
I’m very curious about this: Why is it that when we deal with microcontrollers, they prefer C instead of C++? Based on my researches, C and Assembly language is the usual programming language for these devices. I only know C++ and Assembly Language. So in this case, should I start learning C or stick with Assembly language and if so, what compiler should I use because I only know the Turbo Assembler.
Thanks and more power! 🙂
C is more low-level and does just exactly what you say. It is more adapted to low-resources environments such as micro-controllers.
C++ has some features which requires additional resources (such as OOP, exception, and so on).
Moreover the micro-controller does not have the same features as your computer’s CPU. It could for example not support dynamic library loading and even for static libraries you’re limited in size as your chip doesn’t have many memory.
Usually, micro-controllers expose special input/output library, and the stdlib is not always available.
What you need is a cross-compiler for your micro-controller specifically.
Then you can write your program in C and ASM.
If the chip supports it, you can re-compile the stdlib to use the standard C features, and then you can eventually (once again if the chip has enough resources) build a C++ cross-compiler and then the STL. Then you will be able to build C++ program on your chip, but the program will weight much more than the original C program.