Answer the question
In order to leave comments, you need to log in
Using C++ in Keil?
Question for those who are programming stm32 microcontrollers.
It so happened that it is more convenient for me to write a program in C ++ for microcontrollers than in C. But judging by the examples of other people who program stm32, C ++, to put it mildly, is not held in high esteem. Although there is an opportunity to program on it (at least in Keil).
Accordingly, I have a question - is C ++ worse in performance compared to C? Is the code getting bigger? Is the code not optimal?
Why is everyone trying to stick to C?
Answer the question
In order to leave comments, you need to log in
1. C libraries are usually consistent. Taking a library in C++, it is not clear what will be inside - template magic or C++ of the 98 model. The project may not have support for exceptions, but the library will actively use them. Etc. That is, even choosing C ++, it is much easier to use C libraries. And there, it’s not far from a clean sishka.
2. Higher requirements for the skill of programmers. For example, the notorious virtual methods give an overhead, but templates do not, but everyone needs to explain how to write in C ++ with less overhead than in C.
In general, for iron, I prefer C ++ without fanaticism, with libraries , which have a pure C interface.
because C is a classic of the genre, and why many people love the classics is a rhetorical question, someone does not like fashion trends, someone is just lazy, and so on ... And if we talk about the technical side of things, it has already been written that there is
a) overhead
b) it is not clear or there is no certainty that this overhead will pay off its existence, that is, some C ++ chips are appropriate, and some are “expensive” for a controller or task. For example, RTTI is too hard
d) if the command works, then there is a chance that someone will want to try all these new goodies, that is, a pandorra's box opens, it turns out, for example, that RTTI ate half of the MK's memory.
e) if in C it was clearly clearly visible that the INIT () function is called here, then in C ++ it is clearly not visible that the constructor is called, but it is clear that there is a new operator, but what is stuffed in this constructor of a complex object - you need to look , and when viewing, you see that the ancestor constructor and class member constructors are called. That is, C is more assembler, for each instruction it is easier to see what it translates into at the assembler level.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question