Home c++ The use of C++ in microcontrollers

The use of C++ in microcontrollers

Author

Date

Category

Please tell me whether you can use C++ to program the microcontroller?

Is there a role which no restrictions for the C++ language?


Answer 1, Authority 100%

can be used often, but it is necessary to look at the specific implementation. For example, there can be exceptions.

On the other hand, C++ brings some overhead, and microcontroller is often important each byte is not java c large servers, where you can buy a bar or two.

But microcontrollers do not stand still and develop as actually compilers. Perhaps for your controller and your case C++ – the best option

.


Answer 2, Authority 100%

C++ is not only possible, but also be used for programming microcontrollers. How to write here, no exceptions and operators new. To cancel the exceptions there is even a compiler flag, especially for us.
The C++ best B:

  1. Strong typing. If something is wrong, you get an error at compile time rather than searching for it in debugging. An illustrative example, if the function is passed to an enumeration type, and you have entered into the BBC that something is not right (int, for example), the BBC you will pass the compilation in C++ will get a compilation error.
  2. Links. The philosophy of C++: “Do not pay for something you do not need.” Links do not take up space in the memory, with reference to the code looks neater than the code pointer. You can always forget to put the * or & amp;.
  3. Classes (structure). Trite convenient to describe not only the structure but also the action with her. Each register can be wrapped in a wrapper class with methods that its name indicates what you are doing. If the code requires a lot of comments, it is a bad code.
  4. Objects. The function (class class method), you can pass a reference to an object of the microcontroller output, rather than writing a bunch defaynov all registers (easy to make mistakes, to correct a lot, especially for any stm32).
  5. Templates. Forget multiline macros, errors in which extremely difficult to debug, debugger they just do not go down. Templates preprocessor much better.
  6. no overhead. This is a common myth. Competent code written in C++ allows a smaller volume of binaries, ran into the study, even videos from conferences is on yutyube. (I think all the fault references instead of pointers and optimization of template).

Answer 3, Authority 50%

In fact, there are no restrictions, just need the right script linker with the appropriate sections to support exceptions and virtual methods, as well as being relizatsiya allocators / deallokatorov and STL (of course this luxury?). Find a script on the network is not difficult …


Answer 4

Look at the Wiring language used in the Arduino.
This C++ standard library and, without exception, with its special library. Compile it, by the way, mentioned in your tags avr-gcc.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions